openssl req -new
새 인증서 서명 요청을 생성하기 위해 실행할 때 CSR에 포함 할 대체 주체 이름을 묻는 메시지가 표시되도록 OpenSSL을 구성하려고합니다 .
이 [req_attributes]
섹션을 내 섹션에 추가했습니다 openssl.cnf
.
subjectAltName = Alternative subject names
이것은 CSR을 생성 할 때 SAN에 대한 프롬프트가 표시되는 원하는 효과가 있습니다.
$ openssl req -new -out test.csr -key ./test.key <<<
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
State or Province Name (full name) [New York]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Example Co]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:test.example.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Alternative subject names []:DNS:alt1.example.com
위의 예 DNS:alt1.example.com
에서 SAN에 대한 프롬프트가 표시되면 입력했습니다 .
문제는 결과 CSR의 형식이 올바르지 않은 것입니다.
$ openssl req -text -in ./test.csr
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=US, ST=New York, O=The Banes, CN=test.thebanes.org
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
[...]
Exponent: 65537 (0x10001)
Attributes:
X509v3 Subject Alternative Name:unable to print attribute
OpenSSL은 주제 대체 이름 속성의 값을 인쇄 할 수 없다고 불평합니다. 사람들이 원하는대로 대화식으로 프롬프트하지 않고 SAN을 openssl.cnf에 하드 코딩하는 온라인 예에서 나는 이것을 대신 볼 것으로 기대합니다.
Attributes:
X509v3 Subject Alternative Name:
DNS:alt1.example.com
그렇다면 대화식으로 프롬프트가 표시되는 SAN을 사용하여 올바른 형식의 CSR을 어떻게 생성 할 수 있습니까?
답변
나는이 작은 너겟과 싸웠습니다 …이 얼마나 PITA입니까!
내 솔루션 : 모든 openssl.cnf 파일을 템플릿 툴킷 파일로 이동하여 sans 조각 만 교체 조각으로 남겨두고 perl 스크립트를 그 주위에 감쌌습니다.
perl 스크립트는 SAN 항목을 입력하라는 메시지를 표시 한 다음 템플릿에 삽입하고 템플릿을 임시 파일에 저장 한 다음 임시 파일을 가리키는 -config 옵션을 사용하여 openssl req를 호출합니다. CSR이 생성 된 후 임시 파일을 삭제하십시오.
: 당신은 또한보고 할 수 있습니다 http://www.openssl.org/docs/apps/config.html
실행 직전에 $ ENV를 재정의하고 perl 또는 shell에서 openssl req에 대한 호출을 래핑하고 약간 더 효율적인 방식으로 동일한 것을 달성하는 다른 사람들이 있습니다 : http://blog.loftninjas.org/2008/11/11/ subsaltalt-with-openssl /을 사용하여 구성 -sl- 요청
답변
나는 또한 해결책을 찾고 있습니다. 그리고 이것은 당신이 원하는 것입니다 :
[req]
default_bits = 2048
default_key_file = private.key.pem
...
...
attributes = req_attributes
[req_attributes]
subjectAltName = Alternative DNS names, Email adresses or IPs (comma seperated list)
#optional default value
subjectAltName_default = DNS:myhost.com.au,IP:127.0.0.1,EMAIL:my@here.org
그리고 대체 주제 이름을 묻는 메시지가 표시됩니다. 🙂
#openssl req -in mytest1/temp.csr.pem -noout -text
Certificate Request:
Data:
Version: 0 (0x0)
Subject: C=DE, ST=Sachsen, L=Heidenau, O=IT Rab\xC3\xB6se, OU=ssl
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (1024 bit)
Modulus (1024 bit):
00:d8:cd:14:ca:d0:06:6c:8c:11:e9:52:bc:46:39:
c1:cf:5a:6e:dd:3b:a8:85:15:6b:13:82:82:4a:48:
cb:53:ea:70:ea:f4:02:b2:ef:b1:41:b2:d7:11:c7:
11:ba:07:1b:be:8c:30:bc:60:d2:82:83:a1:e1:19:
75:3b:69:03:01:3c:2b:7b:85:f4:2e:a9:58:68:8f:
0e:f4:5e:50:e1:3f:9e:cf:46:a0:eb:69:aa:1e:cb:
3a:99:cb:1d:93:60:d0:3b:38:96:87:45:19:51:f4:
40:72:e5:a7:5e:62:37:41:44:48:64:47:95:14:97:
4f:27:d0:0c:e7:6f:c1:e1:37
Exponent: 65537 (0x10001)
Attributes:
X509v3 Subject Alternative Name:DNS:www.google.de,EMAIL:im@you.org
Signature Algorithm: sha1WithRSAEncryption
9d:2b:e4:eb:1b:c0:b6:0b:b4:62:a7:4d:01:68:98:68:36:98:
1e:e9:bc:59:24:0f:1b:32:7b:da:9d:39:a4:0f:2c:70:3e:aa:
f7:07:e7:6b:9b:3b:00:b3:71:e0:54:07:78:c7:6e:57:e3:89:
07:e1:93:f1:77:e7:cc:0e:d0:ed:c5:d0:a3:5d:1a:cd:bb:d8:
5f:64:25:81:1b:a8:2f:ef:c7:84:7a:f6:b8:52:4e:4c:1c:8d:
83:b7:9b:02:8e:b2:39:68:a1:fe:f1:59:8b:e0:c4:91:f1:a9:
c7:b3:82:a3:d2:92:2b:e5:79:9f:29:b6:63:e7:cf:9d:17:98:
fe:70
답변
이 “subjectAltName”은이 섹션에 없어야합니다. attributes = req_attributes. 그러나 req_extensions = 섹션에서 (원하는대로 호출하십시오).
그리고 모든 BS가 필요하지 않습니다.
subjectAltName = Alternative subject names
subjectAltName_default = DNS:www.g00gle.com
원하는 것을 원하는만큼 입력하십시오.
subjectAltName = DNS:*.g00gle.com, DNS:g00gle.com, DNS:192.168.1.2
(마지막으로 ” https://192.168.1.2 ” 와 같은 내부 액세스 를 경고없이 수행함)
그래서 같은 :
[ req ]
req_extensions = my_extensions
[my_extensions]
subjectAltName = DNS:*.g00gle.com, DNS:g00gle.com, DNS:192.168.1.2
건배!