どうやら最新版バージョン 44.0.2403.89 mのChromeブラウザで、オレオレ証明書を利用したサイトにアクセスすると「この接続ではプライバシーが保護されません」という警告が、頻繁にでるようになり、まともに操作できなくなるらしい。
IEでは、毎回、下記のような警告がでるが、それほど気にすることはなかった。
「とりあえずIEか、Firefoxを使ってよ!」と言い放ち、軽く流してしまいたい所だけど、潔く対応することにしましょう。
下記のサイトを参考に作業を進める。
(大変わかりやすいサイトで助かりました。)
Linux – 独自SSLサーバ認証局(CA)作成とサーバ証明書発行 – Qiita
そして、「 Windowsでは2017年1月1日以降、SHA1証明書サイトへのSSL通信が接続拒否される」らしいので、どうせならSHA-2証明書で行うことにしょう。
httpd – CentOS6などで俺俺CAとSHA2証明書を作るときのメモ – Qiita
SHA-1 証明書の受付終了と SHA-2 証明書への移行について|サイバートラスト
認証局構築
openssl.cnfを修正する。
1 2 3 4 5 6 7 8 9 10 11 |
[root]# vi /etc/pki/tls/openssl.cnf (中略) #################################################################### [ CA_default ] #dir = /etc/pki/CA # Where everything is kept (コメントアウト) dir = /etc/ssl/ramudaCA # (変更) certs = $dir/certs # Where the issued certs are kept crl_dir = $dir/crl # Where the issued crl are kept database = $dir/index.txt # database index file. (中略) |
CA用に下記のディレクトリーをそれぞれ作成し、秘密鍵が置かれるprivateディレクトリーは権限を0x700とします。
1 2 3 4 5 |
[root]# mkdir -p /etc/ssl/ramudaCA/certs [root]# mkdir -p /etc/ssl/ramudaCA/private [root]# mkdir -p /etc/ssl/ramudaCA/crl [root]# mkdir -p /etc/ssl/ramudaCA/newcerts [root]# chmod 700 /etc/ssl/ramudaCA/private/ |
シリアルを初期化
1 |
[root]# echo "01" > /etc/ssl/ramudaCA/serial |
証明書データベースを初期化します。
1 |
[root]# touch /etc/ssl/ramudaCA/index.txt |
ここまでの作業で下記のようになりました。
1 2 3 4 5 6 7 8 |
[root]# ls -l /etc/ssl/ramudaCA/ total 20 drwxr-xr-x 2 root root 4096 Jul 24 14:21 certs drwxr-xr-x 2 root root 4096 Jul 24 14:22 crl -rw-r--r-- 1 root root 0 Jul 24 14:26 index.txt drwxr-xr-x 2 root root 4096 Jul 24 14:22 newcerts drwx------ 2 root root 4096 Jul 24 14:21 private -rw-r--r-- 1 root root 3 Jul 24 14:25 serial |
CA証明書/秘密鍵作成
自己署名済みの証明書と秘密鍵を作成します。/etc/pki/tls/openssl.cnf のdafault_mdの指定がCentOS6まではsha1なので、
-sha256のオプションを明示します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root]# cd /etc/ssl/ramudaCA/ [root ramudaCA]# openssl req -new -x509 -newkey rsa:2048 -out cacert.pem -keyout private/cakey.pem -days 1825 -sha256 Generating a 2048 bit RSA private key ..................................................................................................................................+++ .........................+++ writing new private key to 'private/cakey.pem' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- 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) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:Chiyoda-ku Organization Name (eg, company) [Default Company Ltd]:Ramuda Co.,Ltd Organizational Unit Name (eg, section) []:Network Dept. Common Name (eg, your name or your server's hostname) []:ramuda.co.jp Email Address []:webmaster@ramuda.co.jp |
下記のファイルが作成される。
1 2 |
/etc/ssl/ramudaCA/cacert.pem : 自己署名済みCA証明書 /etc/ssl/ramudaCA/private/cakey.pem : CA証明書の秘密鍵 |
CA証明書の秘密鍵は他人にみられると困るので、こうします。
1 2 |
[root ramudaCA]# chown root:root /etc/ssl/ramudaCA/private/cakey.pem [root ramudaCA]# chmod 600 /etc/ssl/ramudaCA/private/cakey.pem |
証明書が正しく出来たか確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
[root ramudaCA]# openssl x509 -in /etc/ssl/ramudaCA/cacert.pem -text Certificate: Data: Version: 3 (0x2) Serial Number: 13491930018308904667 (0xbb3cf6de4bbb56db) Signature Algorithm: sha256WithRSAEncryption Issuer: C=JP, ST=Tokyo, L=Chiyoda-ku, O=Ramuda Co.,Ltd, OU=Network Dept., CN=ramuda.co.jp/emailAddress=webmaster@ramuda.co.jp Validity Not Before: Jul 24 05:51:39 2015 GMT Not After : Jul 22 05:51:39 2020 GMT Subject: C=JP, ST=Tokyo, L=Chiyoda-ku, O=Ramuda Co.,Ltd, OU=Network Dept., CN=ramuda.co.jp/emailAddress=webmaster@ramuda.co.jp Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:eb:c2:fd:31:88:4e:b3:f9:04:d0:3a:12:e9:db: 95:b7:a0:96:c2:5c:5c:2b:71:45:19:cb:fa:c8:0a: (中略) 99:6c:ab:85:1c:82:36:1b:7b:8c:a9:c5:10:19:e8: 14:11 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Subject Key Identifier: 02:CE:E4:52:CF:67:46:B6:20:8D:56:E1:D8:92:A0:33:46:2D:86:01 X509v3 Authority Key Identifier: keyid:02:CE:E4:52:CF:67:46:B6:20:8D:56:E1:D8:92:A0:33:46:2D:86:01 X509v3 Basic Constraints: CA:TRUE Signature Algorithm: sha256WithRSAEncryption 1b:3e:b4:48:2d:a7:85:e5:bd:7c:d0:5b:7e:8a:9f:1e:23:07: f4:d9:b7:ae:69:57:4e:d8:d8:b8:e7:17:6d:03:04:07:ff:3c: (中略) fe:b9:ff:c7:78:b4:8a:28:30:e6:4c:68:13:2e:1e:6e:8d:94: 01:06:6f:22 -----BEGIN CERTIFICATE----- MIIEITCCAwmgAwIBAgIJALs89t5Lu1bbMA0GCSqGSIb3DQEBCwUAMIGmMQswCQYD VQQGEwJKUDEOMAwGA1UECAwFVG9reW8xEzARBgNVBAcMCkNoaXlvZGEta3UxFzAV (中略) AHSvIK2uI8NZyhYv6BJYyRqBH7Y3LOByM6EPZKDlgpgx5ftkrUiIMq48wyic+SUb qa9+gzmgZiNWCMObpK98itDJngyhytQjoyzl2hm7tf65/8d4tIooMOZMaBMuHm6N lAEGbyI= -----END CERTIFICATE----- |
ブラウザにCA証明書を組み込む
ブラウザに取り込めるDER形式にエンコードします。
1 |
[root ramudaCA]# openssl x509 -inform PEM -outform DER -in /etc/ssl/ramudaCA/cacert.pem -out /etc/ssl/ramudaCA/ramudaCAcert.der |
作成されたramudaCAcert.derは、利用するPCにダウンロードして「ルート証明書ストア」などにインストールする必要があります。
サーバ証明書
作成した自己認証CA局を使って目的のサイト自体の証明書を発行します。
以下のようなディレクトリを作成しました。
1 |
[root]# mkdir -p /etc/ssl/ramuda.co.jp |
鍵ペアと証明書要求(CSR)ファイルを作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@IPD-0185 ~]# openssl req -new -sha256 -keyout /etc/ssl/ramuda.co.jp/aipo_server_key.pem -out /etc/ssl/ramuda.co.jp/aipo_server_csr.pem Generating a 2048 bit RSA private key ................................................................................................+++ ....................................................................................+++ writing new private key to '/etc/ssl/ramuda.co.jp/aipo_server_key.pem' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- 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) [XX]:JP State or Province Name (full name) []:Tokyo Locality Name (eg, city) [Default City]:Chiyoda-ku Organization Name (eg, company) [Default Company Ltd]:Ramuda Co.,Ltd Organizational Unit Name (eg, section) []:Network Dept. Common Name (eg, your name or your server's hostname) []:ramuda.co.jp Email Address []:webmaster@ramuda.co.jp Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: |
作成が終わると以下のファイルができあがります。
1 2 |
/etc/ssl/ramudua.co.jp/aipo_server_csr.pem : サーバ証明書要求(CSR) /etc/ssl/ramuda.co.jp/aipo_server_key.pem : サーバ秘密鍵 |
自己認証CA局で署名(CA管理者)
サーバ証明書要求(CSR)を先ほど作成した自己認証CA局で署名します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
[root@IPD-0185 ~]# openssl ca -md sha256 -out /etc/ssl/ramuda.co.jp/aipo_server_cert.pem -infiles /etc/ssl/ramuda.co.jp/aipo_server_csr.pem Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for /etc/ssl/ramudaCA/private/cakey.pem: Check that the request matches the signature Signature ok Certificate Details: Serial Number: 2 (0x2) Validity Not Before: Jul 24 07:01:27 2015 GMT Not After : Jul 23 07:01:27 2016 GMT Subject: countryName = JP stateOrProvinceName = Tokyo organizationName = Ramuda Co.,Ltd organizationalUnitName = Network Dept. commonName = ramuda.co.jp emailAddress = webmaster@ramuda.co.jp X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 38:7D:05:4A:BA:4D:1F:30:E0:35:17:0F:72:EF:4B:DA:DC:2B:40:88 X509v3 Authority Key Identifier: keyid:02:CE:E4:52:CF:67:46:B6:20:8D:56:E1:D8:92:A0:33:46:2D:86:01 Certificate is to be certified until Jul 23 07:01:27 2016 GMT (365 days) Sign the certificate? [y/n]:y 1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated |
証明書が正しく出来たかを確認する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
[root]# openssl x509 -in /etc/ssl/ramuda.co.jp/aipo_server_cert.pem -text Certificate: Data: Version: 3 (0x2) Serial Number: 2 (0x2) Signature Algorithm: sha256WithRSAEncryption Issuer: C=JP, ST=Tokyo, L=Chiyoda-ku, O=Ramuda Co.,Ltd, OU=Network Dept., CN=ramuda.co.jp/emailAddress=webmaster@ramuda.co.jp Validity Not Before: Jul 24 07:01:27 2015 GMT Not After : Jul 23 07:01:27 2016 GMT Subject: C=JP, ST=Tokyo, O=Ramuda Co.,Ltd, OU=Network Dept., CN=ramuda.co.jp/emailAddress=webmaster@ramuda.co.jp Subject Public Key Info: Public Key Algorithm: rsaEncryption Public-Key: (2048 bit) Modulus: 00:ea:55:dc:db:6b:d6:8a:f3:f1:71:a2:91:4c:58: e8:04:f5:9e:1c:24:6b:fb:10:1c:4b:96:8e:02:0a: (中略) 0a:05:db:ee:1e:7f:54:22:58:90:1e:f4:e1:c5:8e: 2c:6a:92:47:33:97:a5:69:b3:b2:b4:71:c0:a3:cf: de:17 Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 38:7D:05:4A:BA:4D:1F:30:E0:35:17:0F:72:EF:4B:DA:DC:2B:40:88 X509v3 Authority Key Identifier: keyid:02:CE:E4:52:CF:67:46:B6:20:8D:56:E1:D8:92:A0:33:46:2D:86:01 Signature Algorithm: sha256WithRSAEncryption 98:5f:6a:02:0a:4f:68:8e:64:4f:df:05:78:4e:26:ca:4a:b4: bd:d8:b3:d8:c7:05:a2:da:1e:a0:d6:04:6b:c3:cd:4e:92:93: (中略) a4:63:23:7b:a9:c5:c6:ea:b7:b7:4e:3c:9a:11:da:aa:2d:7a: 0e:7c:71:ba -----BEGIN CERTIFICATE----- MIIELzCCAxegAwIBAgIBAjANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCSlAx DjAMBgNVBAgMBVRva3lvMRMwEQYDVQQHDApDaGl5b2RhLWt1MRcwFQYDVQQKDA5S (中略) SfyENOswi5jnTc5xW5WPIA8sACIrXJ4ZGFPC96w+myJDS1wsuXKxXPrV0bDopGMj e6nFxuq3t048mhHaqi16Dnxxug== -----END CERTIFICATE----- |
出来上がったファイルはこんな感じとなります。
1 2 3 4 5 |
[root]# ls -l /etc/ssl/ramuda.co.jp/ total 16 -rw-r--r-- 1 root root 4735 Jul 24 15:37 aipo_server_cert.pem サーバ証明書(署名済み) -rw-r--r-- 1 root root 1090 Jul 24 15:30 aipo_server_csr.pem サーバ証明書要求(CSR) ←もういらない!? -rw-r--r-- 1 root root 1834 Jul 24 15:30 aipo_server_key.pem サーバ秘密鍵 |
パスフレーズをキャンセルする
サーバ再起動時にいちいちパスフレーズを入力するのが面倒です。 パスフレーズは、サーバ秘密鍵に書かれているのでこんな感じでRSAキーを書き込みます。
1 2 3 4 5 6 7 8 9 |
[root]# openssl rsa -in /etc/ssl/ramuda.co.jp/aipo_server_key.pem -out /etc/ssl/ramuda.co.jp/aipo_server_key.pem.nopass Enter pass phrase for /etc/ssl/ramuda.co.jp/aipo_server_key.pem: writing RSA key [root]# ls -l /etc/ssl/ramuda.co.jp/ total 20 -rw-r--r-- 1 root root 4735 Jul 24 15:37 aipo_server_cert.pem -rw-r--r-- 1 root root 1090 Jul 24 15:30 aipo_server_csr.pem -rw-r--r-- 1 root root 1834 Jul 24 15:30 aipo_server_key.pem -rw-r--r-- 1 root root 1679 Jul 24 15:46 aipo_server_key.pem.nopass パスフレーズが書き込まれている秘密鍵 |
証明書と秘密鍵をサーバーへ組み込む
AIPOのSSL対応は、SSLへの対応|無料グループウェア「アイポ」に記載されています。が、しかし、結局正当な方式がないので、リバースプロキシを使用して簡単にAipoを既存のApacheと連携させる+SSL対応+自動起動|成長の果実の方式を利用しています。
出来上がった証明書と(パスフレーズ書き込み済みの)秘密鍵を下記のように組み込み、apahceを再起動する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[root]# vi /etc/httpd/conf.d/ssl.conf (省略) # SSL Protocol support: # List the enable protocol levels with which clients will be able to # connect. Disable SSLv2 access by default: SSLProtocol All -SSLv2 -SSLv3 # SSL Cipher Suite: # List the ciphers that the client is permitted to negotiate. # See the mod_ssl documentation for a complete list. SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW # Server Certificate: # Point SSLCertificateFile at a PEM encoded certificate. If # the certificate is encrypted, then you will be prompted for a # pass phrase. Note that a kill -HUP will prompt again. A new # certificate can be generated using the genkey(1) command. #SSLCertificateFile /etc/pki/tls/certs/localhost.crt <span style="color: #ff0000;">SSLCertificateFile /etc/ssl/ramuda.co.jp/aipo_server_cert.pem</span> # Server Private Key: # If the key is not combined with the certificate, use this # directive to point at the key file. Keep in mind that if # you've both a RSA and a DSA private key you can configure # both in parallel (to also allow the use of DSA ciphers, etc.) #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key <span style="color: #ff0000;">SSLCertificateKeyFile /etc/ssl/ramuda.co.jp/aipo_server_key.pem.nopass </span> |
正しく整合性が取れると
ルート証明書をアクセスするPCにインストールし、ルート署名付きのサーバー証明書との整合性がとれると、Chormeの場合下記のような表示となる。
鍵マークが黄緑色になる。
また、SHA256を利用したので、鍵マークをクリックして証明書の詳細を表示した際に
「××××への接続は新しい暗号スィートにより暗号化されています」の表示になっているはずである。