èªå·±ç½²åãªSSL証ææ¸ãä½æããæ¹æ³ããã¡ã¢ã¨ãã¦æ¸ãã¦ãããã¨æãã¾ãã¦ããã¹ããããã§ã使ã£ãããã¾ãããã
ä»å使ç¨ãããOpenSSLã®ãã¼ã¸ã§ã³ã¯ãã¡ãã
$ openssl version OpenSSL 1.1.0g 2 Nov 2017
æé ã¯ã
- ç§å¯éµã®ä½æ
- ãªãã±ã§ãã¹ã¯ã¼ãã®è§£é¤æ¹æ³
- CSRã®ä½æï¼èªå·±ç½²å証ææ¸ãä½æããå ´åã¯ãã¹ãããå¯è½ï¼
- ç½²å
ã¨ãªãã¾ãã
ã¾ãã¯ãç§å¯éµã®ä½æã
$ openssl genrsa -aes128 -out sample.key 2048
ç§å¯éµã¯ã以ä¸ã®æ å ±ã§ä½æããéµã®ä¿è·ã¯AES-128ãæå®ã
- éµã¢ã«ã´ãªãºã ⦠RSA
- éµã®é·ã ⦠2048 bit
- ãã¹ãã¬ã¼ãº ⦠ï¼ããã§ã¯è¨è¼ãçç¥ï¼
Apacheãªã©ã®Webãµã¼ãã¼ã§ä½¿ãå ´åãèµ·åæã«ãã¹ã¯ã¼ããæ±ããããã®ãå«ãªã解é¤ããæ¹æ³ãã
$ openssl rsa -in sample.key -out sample.key
æåãããã¹ã¯ã¼ããªãã§ä½ãå ´åã¯ããã¡ãã§ãï¼ç§å¯éµã®ä¿è·æå®ããªããªãï¼ã
$ openssl genrsa -out sample.key 2048
CSRã®ä½æã
$ openssl req -new -key sample.key -out sample.csr
èãããæ å ±ã¯ããããªæãã§ãã
Country Name (2 letter code) [AU]: State or Province Name (full name) [Some-State]: Locality Name (eg, city) []: Organization Name (eg, company) [Internet Widgits Pty Ltd]: Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []: Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
challenge passwordã¯ãé常空æ¬ã®ã¾ã¾ã«ãã¦ããã¾ãããã以å¤ã¯ãé©å®è¨å®ã
ä»åãCommon Nameã®ã¿ãhoge.comãã¨æå®ãã¦ããã¾ããã
$ Common Name (e.g. server FQDN or YOUR name) []:hoge.com
Common Nameã«ã*.example.comãã®ããã«ãã*ããå«ãããã®ã«ããã¨ãã¯ã¤ã«ãã«ã¼ã証ææ¸ã«ãªãã¾ãã
証ææ¸ã¸ã®ç½²åãé常ã¯ã次ã®ããã«ãªãã¾ãï¼æå¹æéã¯ã365æ¥ã«ãã¦ãã¾ãï¼ã
$ openssl x509 -req -days 365 -in sample.csr -signkey sample.key -out sample.crt
確èªã
$ openssl x509 -text -in sample.crt --noout Certificate: Data: Version: 3 (0x2) Serial Number: da:c9:a5:f1:db:cc:58:97 Signature Algorithm: sha256WithRSAEncryption Issuer: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd, CN = hoge.com Validity Not Before: Aug 3 12:54:47 2018 GMT Not After : Aug 3 12:54:47 2019 GMT Subject: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd, CN = hoge.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) ......çç¥
è¤æ°ãã¹ãåã«å¯¾å¿ãããï¼SANï¼Subject Alternative Nameï¼
é常ãOpenSSLã§ä½æããSSL証ææ¸ã¯ãã²ã¨ã¤ã®Subjectãæã¡ãã²ã¨ã¤ã®ãã¹ãåã«å¯¾ãã¦ã®ã¿æå¹ã§ãã
ã§ãããX509æ¡å¼µã®SANï¼Subject Alternative Nameï¼ã使ç¨ããã¨ãè¤æ°ã®ãã¹ãåã«å¯¾å¿ããããã¨ãã§ãã¾ãã
è¤æ°ãã¹ãåã«å¯¾å¿ãããå ´åã¯ã次ã®ãããªããã¹ããã¡ã¤ã«ãç¨æãã¾ãããã¡ã¤ã«åã¯ããªãã§ãããã§ãã
subjectnames.txt
subjectAltName = DNS:test.com, DNS:*.example.com, DNS:bar.com, IP:172.17.0.2
ãã¹ãåãæ¸ãå ´åã¯ãDNSãã§ãIPã¢ãã¬ã¹ã§æ¸ãå ´åã¯ãIPãã§æå®ãã¾ããã¯ã¤ã«ãã«ã¼ãï¼*ï¼ã使ç¨å¯è½ã§ãã
ããããç½²åæã«ã-extfileããªãã·ã§ã³ã§æå®ãã¾ãã
$ openssl x509 -req -days 365 -in sample.csr -signkey sample.key -out sample.crt -extfile subjectnames.txt
確èªã
$ openssl x509 -text -in sample.crt --noout
ãX509v3 Subject Alternative Nameãã«ãæå®ããsubjectAltNameãå«ã¾ããããã«ãªãã¾ãã
X509v3 extensions: X509v3 Subject Alternative Name: DNS:test.com, DNS:*.example.com, DNS:bar.com, IP Address:172.17.0.2
ããã§æ³¨æã§ãããSANæ¡å¼µãå«ãã証ææ¸ã¯ãå
ã®Subjectãç¡è¦ããããã«ãªãã¾ãããã®ãã¼ã¸ã§ä½æãã証ææ¸ã§ããã¨ãCommon Nameããhoge.comãã«
ãã¦ãã¾ããã
$ Common Name (e.g. server FQDN or YOUR name) []:hoge.com
SANæ¡å¼µã使ç¨ããå ´åããã®è¨¼ææ¸ã§ãhoge.comãã¯ç¡å¹ã¨ãªãã¾ãã®ã§ã注æãã¾ãããã
ãã®SSL証ææ¸ãApacheã«çµã¿è¾¼ãã§ãã証ææ¸ã®ãµãã¸ã§ã¯ãã®ä»£æ¿åãã確èªããã¨ããããªæãã«è¦ããã¨ãã§ãã¾ãã
ãªãã±
CSRãªãã§ãç§å¯éµãããããªãèªå·±ç½²å証ææ¸ãä½æããå ´åã¯ããã¡ãã
$ openssl req -new -x509 -days 365 -key sample.key -out sample.crt
ã-extfileãã¯ãx509ãµãã³ãã³ãã®ãªãã·ã§ã³ã®ãããªã®ã§ããã¡ãã§ã¯ã ãªã£ã½ãã§ããã
åèï¼
ãããã§ãã·ã§ãã«SSL/TLS
- ä½è : Ivan RistiÄ,é½è¤åé
- åºç社/ã¡ã¼ã«ã¼: ã©ã ããã¼ã
- çºå£²æ¥: 2017/03/31
- ã¡ãã£ã¢: ããã¹ã
- ãã®ååãå«ãããã° (2件) ãè¦ã