Microsoft MVP성태의 닷넷 이야기
개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3) [링크 복사], [링크+제목 복사],
조회: 3309
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

(시리즈 글이 10개 있습니다.)
개발 환경 구성: 555. openssl - CA로부터 인증받은 새로운 인증서를 생성하는 방법
; https://www.sysnet.pe.kr/2/0/12570

개발 환경 구성: 565. PowerShell - New-SelfSignedCertificate를 사용해 CA 인증서 생성 및 인증서 서명 방법
; https://www.sysnet.pe.kr/2/0/12588

개발 환경 구성: 654. openssl - CA로부터 인증받은 새로운 인증서를 생성하는 방법 (2)
; https://www.sysnet.pe.kr/2/0/13187

개발 환경 구성: 662. openssl - 윈도우 환경의 명령행에서 SAN 적용하는 방법
; https://www.sysnet.pe.kr/2/0/13235

개발 환경 구성: 663. openssl을 이용해 인트라넷 IIS 사이트의 SSL 인증서 생성
; https://www.sysnet.pe.kr/2/0/13236

개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3)
; https://www.sysnet.pe.kr/2/0/13371

개발 환경 구성: 686. 비주얼 스튜디오로 실행한 ASP.NET Core 사이트를 WSL 2 인스턴스에서 https로 접속하는 방법
; https://www.sysnet.pe.kr/2/0/13442

개발 환경 구성: 687. OpenSSL로 생성한 사용자 인증서를 ASP.NET Core 웹 사이트에 적용하는 방법
; https://www.sysnet.pe.kr/2/0/13443

Linux: 62. 리눅스/WSL에서 CA 인증서를 저장하는 방법
; https://www.sysnet.pe.kr/2/0/13445

닷넷: 2162. ASP.NET Core 웹 사이트의 SSL 설정을 코드로 하는 방법
; https://www.sysnet.pe.kr/2/0/13447




openssl - 인증서 버전(V1 / V3)

인증서를 보면, 어떤 경우는 Version이 V1이고,

cert_version_v1_v3_2.png

어떤 경우는 V3입니다. 제가 인증서 규약의 이력까지 꿰고 있지는 않아서 특정하게 답을 할 수는 없지만 아래의 글을 보면,

openssl keeps creating v1 certificate instead of v3
; https://serverfault.com/questions/979094/openssl-keeps-creating-v1-certificate-instead-of-v3

openssl의 경우 extension을 지정하느냐의 여부에 따라 다르다고 합니다. 예를 들어 볼까요? 우선 공통적으로 사용할 CA 인증서를 생성해 두고,

// CA 인증서 생성 단계
c:\temp> openssl genrsa -out win2008r2_ca.key 2048
c:\temp> openssl req -x509 -new -nodes -key win2008r2_ca.key -sha256 -days 3650 -out win2008r2_ca.crt -subj "/CN=win2008r2_ca"

// 인증서의 개인키까지 미리 생성해 두고,
C:\temp2> openssl genrsa -out win2008r2.key 2048

이것으로부터 다음의 명령어 단계에서는 extension을 사용하지 않으므로 Version 1 인증서가 생성됩니다.

C:\temp2> openssl req -key win2008r2.key -new -out win2008r2_v1.csr -subj "/CN=win2008r2"

C:\temp2> openssl x509 -req -days 3650 -in win2008r2_v1.csr -CA win2008r2_ca.crt -CAkey win2008r2_ca.key -CAcreateserial -out win2008r2_v1.crt

반면, 다음과 같이 cnf 파일을 경유해 extension을 지정하게 되면,

// https://www.sysnet.pe.kr/2/0/13368#user_cert

C:\temp> type win2008r2.cnf
...[생략]...

[ x509_ext ]
extendedKeyUsage = serverAuth
authorityKeyIdentifier = keyid,issuer
subjectAltName = $ALTNAMES
keyUsage = digitalSignature,keyEncipherment

c:\temp> openssl req -key win2008r2.key -new -out win2008r2_v3.csr -config win2008r2.cnf

c:\temp> openssl x509 -req -days 3650 -in win2008r2_v3.csr -CA win2008r2_ca.crt -CAkey win2008r2_ca.key -out win2008r2_v3.crt -extfile win2008r2.cnf -extensions x509_ext     // https://www.sysnet.pe.kr/2/0/12570

Version 3에 해당하는 인증서가 생성됩니다.

cert_version_v1_v3_1.png




참고로, 개별 인증서를 덤프해 보면,

c:\temp> certutil -dump win2008r2_v1.crt
X509 Certificate:
Version: 1
Serial Number: 266eaf8690080b39c7c0c1c94801079c021564e8
Signature Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.11 sha256RSA
    Algorithm Parameters:
    05 00
Issuer:
    CN=win2008r2_ca
  Name Hash(sha1): 578d38c659713de7083f3ce2aa7501ded7648338
  Name Hash(md5): 32befab375694c94ab4f04c9eab3824f

 NotBefore: 2023-06-15 오후 2:27
 NotAfter: 2033-06-12 오후 2:27

Subject:
    CN=win2008r2
  Name Hash(sha1): 6389965a435cf7dcafbfc11b914909ef7ca955a4
  Name Hash(md5): 8ed715e917a11604e84557f076cf1e64

Public Key Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.1 RSA (RSA_SIGN)
    Algorithm Parameters:
    05 00
Public Key Length: 2048 bits
Public Key: UnusedBits = 0
    0000  30 82 01 0a 02 82 01 01  00 d6 a6 75 9f 75 b5 19
    ...[생략]...
    0100  f4 96 34 e8 be 46 3a 9a  35 02 03 01 00 01
Certificate Extensions: 0
Signature Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.11 sha256RSA
    Algorithm Parameters:
    05 00
Signature: UnusedBits=0
    0000  41 00 82 75 b6 43 fb 38  fd 7e b6 01 d4 73 04 30
    ...[생략]...
    00f0  05 41 8c 41 f6 9a 70 72  a6 96 a4 2c 40 eb 06 a6
Non-root Certificate
Key Id Hash(rfc-sha1): e9 db 2c 4e ec 8a d2 2d 22 33 a2 b8 d6 0a a5 0f fc 2f a6 bb
Key Id Hash(sha1): 0c fc 50 e2 ec 07 a9 63 16 62 be 9c 9b 55 23 ef 3e 58 1c 61
Key Id Hash(md5): 490edc2518a46c275a93ac90448f3b70
Key Id Hash(sha256): 03a28d05d6910c56cd0c33d7303fe61a8f7d736129905450a25fa0aa168008d2
Cert Hash(md5): d5 a6 8e 9f 0a 5f 28 43 39 5f 47 b3 86 a7 25 5b
Cert Hash(sha1): 7c 35 0a 23 dc 41 93 03 b9 12 a3 68 fe fc 6c 59 92 b8 30 23
Cert Hash(sha256): f81fb90e5736d6ad2efb30fc5f253bc18f1ca1b5e2c3dd82b6011794f53d1705
Signature Hash: 4c74774b3f60423cbab9653a26d25bdf14b55b34c90a155bdf244d6b691d472a
CertUtil: -dump command completed successfully.


C:\temp2> certutil -dump win2008r2_v3.crt
X509 Certificate:
Version: 3
Serial Number: 266eaf8690080b39c7c0c1c94801079c021564e9
Signature Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.11 sha256RSA
    Algorithm Parameters:
    05 00
Issuer:
    CN=win2008r2_ca
  Name Hash(sha1): 578d38c659713de7083f3ce2aa7501ded7648338
  Name Hash(md5): 32befab375694c94ab4f04c9eab3824f

 NotBefore: 2023-06-15 오후 2:35
 NotAfter: 2033-06-12 오후 2:35

Subject:
    CN=win2008r2
  Name Hash(sha1): 6389965a435cf7dcafbfc11b914909ef7ca955a4
  Name Hash(md5): 8ed715e917a11604e84557f076cf1e64

Public Key Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.1 RSA
    Algorithm Parameters:
    05 00
Public Key Length: 2048 bits
Public Key: UnusedBits = 0
    0000  30 82 01 0a 02 82 01 01  00 d6 a6 75 9f 75 b5 19
    ...[생략]...
    0100  f4 96 34 e8 be 46 3a 9a  35 02 03 01 00 01
Certificate Extensions: 5
    2.5.29.37: Flags = 0, Length = c
    Enhanced Key Usage
        Server Authentication (1.3.6.1.5.5.7.3.1)

    2.5.29.35: Flags = 0, Length = 18
    Authority Key Identifier
        KeyID=bfb1bf9dfc9ec4287701e5965860f55966934ee6

    2.5.29.17: Flags = 0, Length = d
    Subject Alternative Name
        DNS Name=win2008r2

    2.5.29.15: Flags = 0, Length = 4
    Key Usage
        Digital Signature, Key Encipherment (a0)

    2.5.29.14: Flags = 0, Length = 16
    Subject Key Identifier
        e9db2c4eec8ad22d2233a2b8d60aa50ffc2fa6bb

Signature Algorithm:
    Algorithm ObjectId: 1.2.840.113549.1.1.11 sha256RSA
    Algorithm Parameters:
    05 00
Signature: UnusedBits=0
    0000  6e 7f 5e d8 0c ad 0a 88  4f a0 89 6c a3 3d c2 f3
    ...[생략]...
    00f0  06 d5 be 08 4a 81 f6 49  59 66 14 0d b3 b2 4b 36
Non-root Certificate
Key Id Hash(rfc-sha1): e9db2c4eec8ad22d2233a2b8d60aa50ffc2fa6bb
Key Id Hash(sha1): 0cfc50e2ec07a9631662be9c9b5523ef3e581c61
Key Id Hash(bcrypt-sha1): 5c4eb93bdb575745224ef3b39a586273d6c0499e
Key Id Hash(bcrypt-sha256): fe12236bad5d4db685d6ed703a57bebda1705aac29ea9b8f49428c2aad8b5718
Key Id Hash(md5): 490edc2518a46c275a93ac90448f3b70
Key Id Hash(sha256): 03a28d05d6910c56cd0c33d7303fe61a8f7d736129905450a25fa0aa168008d2
Key Id Hash(pin-sha256): iQdXgGgrODaR3+at2uGfpdnHp2eT5WMTpohraZ2lITo=
Key Id Hash(pin-sha256-hex): 89075780682b383691dfe6addae19fa5d9c7a76793e56313a6886b699da5213a
Cert Hash(md5): 38fcc39023b77e1c0600f99ca16cc509
Cert Hash(sha1): 339a2121732f32b0cc57fb7d8998c0c700aa0e8a
Cert Hash(sha256): 3b10ac3a702e668278e40e1e61d8ad6fe26300751798d75be997c691564a107c
Signature Hash: 3397c0c581a7978dbd2570e7b4c782e6c0f0d3f3213c5aa318318201b7e81a97
CertUtil: -dump command completed successfully.

차이점은 중간에 "Certificate Extensions" 항목만 있습니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 6/15/2023]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13384정성태6/26/20233708.NET Framework: 2131. C# - Source Generator로 해결하는 enum 박싱 문제파일 다운로드1
13383정성태6/26/20233481개발 환경 구성: 683. GPU 런타임을 사용하는 Colab 노트북 설정
13382정성태6/25/20233532.NET Framework: 2130. C# - Win32 API를 이용한 윈도우 계정 정보 (예: 마지막 로그온 시간)파일 다운로드1
13381정성태6/25/20233948오류 유형: 869. Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
13380정성태6/24/20233382스크립트: 52. 파이썬 3.x에서의 동적 함수 추가
13379정성태6/23/20233424스크립트: 51. 파이썬 2.x에서의 동적 함수 추가
13378정성태6/22/20233305오류 유형: 868. docker - build 시 "CANCELED ..." 뜨는 문제
13377정성태6/22/20237176오류 유형: 867. 파이썬 mysqlclient 2.2.x 설치 시 "Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually" 오류
13376정성태6/21/20233516.NET Framework: 2129. C# - Polly를 이용한 클라이언트 측의 요청 재시도파일 다운로드1
13375정성태6/20/20233148스크립트: 50. Transformers (신경망 언어모델 라이브러리) 강좌 - 2장 코드 실행 결과
13374정성태6/20/20233258오류 유형: 866. 파이썬 - <class 'AttributeError'> module 'flask.json' has no attribute 'JSONEncoder'
13373정성태6/19/20234571오류 유형: 865. 파이썬 - pymssql 설치 관련 오류 정리
13372정성태6/15/20233248개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
13371정성태6/15/20233309개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3)
13370정성태6/14/20233477개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
13369정성태6/13/20233274개발 환경 구성: 679. PyCharm(을 비롯해 JetBrains에 속한 여타) IDE에서 내부 Window들의 탭이 없어진 경우
13368정성태6/13/20233427개발 환경 구성: 678. openssl로 생성한 인증서를 SQL Server의 암호화 인증서로 설정하는 방법
13367정성태6/10/20233547오류 유형: 864. openssl로 만든 pfx 인증서를 Windows Server 2016 이하에서 등록 시 "The password you entered is incorrect" 오류 발생
13366정성태6/10/20233318.NET Framework: 2128. C# - 윈도우 시스템에서 지원하는 암호화 목록(Cipher Suites) 나열파일 다운로드1
13365정성태6/8/20233066오류 유형: 863. MODIFY FILE encountered operating system error 112(failed to retrieve text for this error. Reason: 15105)
13364정성태6/8/20233870.NET Framework: 2127. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 [1]
13363정성태6/7/20233461스크립트: 49. 파이썬 - "Transformers (신경망 언어모델 라이브러리) 강좌" - 1장 2절 코드 실행 결과
13362정성태6/1/20233374.NET Framework: 2126. C# - 서버 측의 요청 제어 (Microsoft.AspNetCore.RateLimiting)파일 다운로드1
13361정성태5/31/20233794오류 유형: 862. Facebook - ASP.NET/WebClient 사용 시 graph.facebook.com/me 호출에 대해 403 Forbidden 오류
13360정성태5/31/20233180오류 유형: 861. WSL/docker - failed to start shim: start failed: io.containerd.runc.v2: create new shim socket
13359정성태5/19/20233500오류 유형: 860. Docker Desktop - k8s 초기화 무한 반복한다면?
1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...