「OpenSSL」 authorityInfoAccess に OCSP サーバ ( OCSP レスポンダ ) の情報を持つ証明書を作成する
OpenSSL で authorityInfoAccess に OCSP サーバ ( OCSP レスポンダ ) の情報を持つ証明書を作成してみたので、メモしておきます。
※ OCSP は証明書の失効状態を取得するためのプロトコルで、証明書失効リスト ( CRL ) の代替策として考えられたものみたいです。RFC は 6960。
・Online Certificate Status Protocol - Wikipedia
http://ja.wikipedia.org/wiki/Online_Certificate_Status_Protocol
・RFC 6960 - X.509 Internet Public Key Infrastructure Online Certificate Status Protocol - OCSP
https://tools.ietf.org/html/rfc6960
openssl.cnf の設定でできるみたいなんですが、CA 証明書とそれで署名された証明書 ( サーバ証明書とか ) では設定箇所が違うので、それぞれ書いておきます。
※ 独自 CA の構築から証明書発行までのやり方は、以下のエントリーにまとめていますので、そちらを参照ください。今回は authorityInfoAccess の設定箇所のみの内容です。
・「OpenSSL」 独自認証局を構築する ( その後証明書発行するまで ) - プログラム日記
http://a4dosanddos.hatenablog.com/entry/2015/03/30/010349
1. CA 証明書の場合
openssl.cnf の [ v3_ca ] セクションに以下を追記する。
[ v3_ca ] authorityInfoAccess = OCSP;URI:http://www.example.com:8888
上記設定した上で作成した CA 証明書が以下。ちゃんと X509v3 extensions の Authority Information Access に OCSP サーバの情報 ( 情報というか OCSP サーバにアクセスする方法かな ) がありますね。
[root@centos62 openssl]# openssl x509 -text -noout -in cacert.pem Certificate: Data: Version: 3 (0x2) Serial Number: f2:8a:6f:46:19:0a:b0:3a Signature Algorithm: sha1WithRSAEncryption Issuer: C=JP, ST=ca, O=ca, OU=ca, CN=www.example.com/emailAddress=ca@example.com Validity Not Before: May 26 15:37:38 2015 GMT Not After : May 25 15:37:38 2018 GMT Subject: C=JP, ST=ca, O=ca, OU=ca, CN=www.example.com/emailAddress=ca@example.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (1024 bit) Modulus: 00:ae:d6:25:04:5c:33:dd:2a:1c:84:65:63:89:31: 86:cc:c4:fd:cf:b3:fb:b4:0d:55:3f:2e:86:19:ef: dc:fc:02:a5:af:92:7d:62:4e:c8:6c:2e:c6:5b:8a: 5e:d7:61:dc:76:66:b1:08:b6:b9:a7:7a:0e:cb:08: 9c:d4:bc:b9:e1:20:b6:dc:63:20:ae:06:94:ef:d6: c1:3b:d9:f5:b7:12:71:72:3e:1b:3e:94:f9:35:13: 36:83:29:57:da:f9:fb:9d:40:90:9e:98:29:9c:24: 32:fd:49:39:64:9c:f9:4d:94:0b:a7:38:5c:f6:f6: 6b:aa:fb:63:b2:2b:4c:72:e1 Exponent: 65537 (0x10001) X509v3 extensions: Authority Information Access: OCSP - URI:http://www.example.com:8888 X509v3 Subject Key Identifier: B2:F9:BC:73:CE:1C:21:6F:75:40:3F:04:42:F8:3F:72:85:14:00:5C X509v3 Authority Key Identifier: keyid:B2:F9:BC:73:CE:1C:21:6F:75:40:3F:04:42:F8:3F:72:85:14:00:5C X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha1WithRSAEncryption 3e:f3:ae:50:98:ab:de:7b:7c:85:4f:33:f6:5c:8e:ec:08:bb: b6:d6:dc:16:ad:e7:67:20:c6:12:95:e6:24:dc:0e:bc:a5:2f: 53:53:e2:ad:ec:87:f5:ed:c5:cc:45:cb:5d:b2:97:38:e2:00: e4:23:df:01:e8:82:ed:a2:cd:70:b2:e9:34:d7:0e:21:36:68: b2:1f:3c:4c:e0:e0:cb:54:29:29:6b:c3:3f:55:80:66:fa:f8: c1:48:cb:c3:2f:02:db:6f:af:84:14:d9:a5:d9:46:db:88:71: 8d:d5:f0:9d:06:be:76:f0:9f:67:54:9b:0b:87:48:be:6c:99: ec:61
2. それ以外の証明書の場合
openssl.cnf の [ usr_cert ] セクションに以下を追記する。
[ usr_cert ] authorityInfoAccess = OCSP;URI:http://www.example.com:8888
上記設定した上で CA から発行した証明書が以下。こっちも X509v3 extensions の Authority Information Access に OCSP サーバの情報がありますね。
[root@centos62 bbb]# openssl x509 -text -noout -in bbb.crt Certificate: Data: Version: 3 (0x2) Serial Number: f2:8a:6f:46:19:0a:b0:3c Signature Algorithm: sha1WithRSAEncryption Issuer: C=JP, ST=ca, O=ca, OU=ca, CN=www.example.com/emailAddress=ca@example.com Validity Not Before: May 26 15:46:45 2015 GMT Not After : May 25 15:46:45 2016 GMT Subject: C=JP, ST=bbb, L=bbb, O=bbb, OU=bbb, CN=www.example.com/emailAddress=bbb@example.com Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:bb:5d:06:76:6a:3b:81:07:48:84:a8:02:e1:43: 88:18:0b:b9:84:02:e6:42:4c:79:af:2c:cc:93:8d: 87:04:f4:4a:46:39:d7:33:9b:85:49:1b:98:37:6c: d9:c6:f2:8e:ab:55:bb:79:69:b7:be:37:3c:57:d2: 25:f5:5e:5a:9e:e0:39:2a:f2:48:5f:d7:6a:d8:b5: f0:8d:bc:40:cd:34:58:cd:5f:da:dd:a6:a1:14:92: e2:a4:db:d3:24:9c:25:d4:48:f9:2f:7f:0d:5b:d3: 47:ab:b2:cd:de:d0:9b:8e:90:c2:8c:4a:c1:f6:a2: a8:32:5c:94:e0:b9:4b:ea:73:b1:34:b5:65:8b:ca: ce:45:d6:b3:55:25:ce:56:b8:2f:88:39:69:5f:95: 32:a5:b4:3c:a2:8f:c1:d2:e0:d7:58:9e:0a:62:8f: a4:b2:19:fc:2f:4f:2b:44:ef:0a:3e:19:db:95:a0: e8:bf:94:4f:84:ee:e2:50:41:e0:53:41:4a:49:f0: ef:34:27:90:38:a1:64:76:22:31:d8:cc:1f:26:5f: 6c:80:c6:e6:1f:1b:3d:1a:fa:1e:31:f9:c4:d4:07: 57:b3:28:79:09:78:4e:e2:50:45:2e:73:af:a8:e5: ab:51:c9:2e:5c:ba:03:fb:cb:83:22:f2:ce:fc:1c: b4:83 Exponent: 65537 (0x10001) X509v3 extensions: Authority Information Access: OCSP - URI:http://www.example.com:8888 X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: B5:B1:E2:C4:C9:A6:44:A8:52:48:52:42:FA:E7:6D:9D:5F:28:91:DF X509v3 Authority Key Identifier: keyid:B2:F9:BC:73:CE:1C:21:6F:75:40:3F:04:42:F8:3F:72:85:14:00:5C Signature Algorithm: sha1WithRSAEncryption 73:d5:41:59:48:57:7b:65:14:05:a4:e3:19:c9:c6:87:25:c9: fc:d4:5c:9a:ee:22:4c:9a:ac:99:9b:90:33:fe:97:84:2e:a2: 2a:67:61:bf:f8:e5:c4:2e:9a:e6:2e:a9:f3:6e:9e:65:56:25: fc:15:a2:8a:22:f5:89:a9:b9:a6:7b:7d:1c:26:fc:9c:9f:8d: 21:26:d2:4e:bc:8e:7a:07:af:aa:16:0b:e1:9a:68:31:d4:c8: c9:70:86:2f:85:e3:fb:1f:93:d2:9d:a9:2d:6c:71:48:f1:59: 51:c4:5f:ac:45:ec:6c:99:b9:d1:87:3c:c6:ef:70:31:5e:01: e6:7d
ドキュメント的には以下あたりでしょうか。
・x509v3_config - X509 V3 certificate extension configuration format
https://www.openssl.org/docs/apps/x509v3_config.html
ちょっと本論からはずれますが、OpenSSL が OCSP サーバとしての機能を持っているみたいです。以下の感じで OCSP サーバが起動できます。
openssl ocsp -index index.txt -port 8888 -rsigner cacert.pem -CA cacert.pem -rkey private/cakey.pem
・ocsp - Online Certificate Status Protocol utility
https://www.openssl.org/docs/apps/ocsp.html
以上です。
[ 環境情報 ]
CentOS 6.2
OpenSSL 1.0.1e