なぜSSLかというと、phpmyadminやらCMSやらをインストールした後、それにログインする際にはSSL環境下でアクセスしたいということからである。
個人的に利用するだけなので、証明書は自己証明でいいと判断。
もちろん、CAcert.orgという無料で証明書を発行してくれるところもある。
まずは自己証明のSSLがOKになったら、そちらに進んでもいいかと思っている。
ただ、CAcert.orgは半年に一回更新をかけないといけないので、ちょっと手間かもしれない。
ちなみに、CAcert.orgで証明書発行しても、ブラウザでは確認が取れていない証明書なのでインストールしないとダメだけど、それでもオレオレ証明書よりはいいかもね。
ともあれ、まずは自己証明から。
# /etc/pki/tls/misc/CA -newca CA certificate filename (or enter to create) ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ Making CA certificate ... Generating a 1024 bit RSA private key ..++++++ .............++++++ writing new private key to '../../CA/private/./cakey.pem' Enter PEM pass phrase: Verifying - Enter PEM pass phrase: ----- ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ ----- Country Name (2 letter code) [GB]:JP State or Province Name (full name) [Berkshire]:Tokyo Locality Name (eg, city) [Newbury]:Minato Organization Name (eg, company) [My Company Ltd]:Private Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:********** Email Address []:dummy@********.***** Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for ../../CA/private/./cakey.pem: Check that the request matches the signature Signature ok ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ Write out database with 1 new entries Data Base Updated # /etc/pki/tls/misc/CA -newreq Generating a 1024 bit RSA private key ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ ----- Country Name (2 letter code) [GB]:JP State or Province Name (full name) [Berkshire]:Tokyo Locality Name (eg, city) [Newbury]:Minato Organization Name (eg, company) [My Company Ltd]:Personal Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:********** Email Address []:dummy@********.*** Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: Request is in newreq.pem, private key is in newkey.pem # /etc/pki/tls/misc/CA -sign Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for ../../CA/private/cakey.pem: Check that the request matches the signature Signature ok ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ Certificate is to be certified until Oct 22 15:18:10 2011 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 ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ -----BEGIN CERTIFICATE----- MIIC1jCCAj+gAwIBAgIBATANBgkqhkiG9w0BAQUFADBmMQswCQYDVQQGEwJKUDEO MAwGA1UECBMFVG9reW8xEDAOBgNVBAoTB1ByaXZhdGUxEjAQBgNVBAMTCVByaXZh ・・・・・・・・・・・・・・・・・・・・ ・・・・・・・・・・・・・・・・・・・・ TIm+tG3jtYsxikhV/1yCbM/WIPa10L6plFcPLTnS43sdzgyo7lUN9fA6FXxp0i43 1lvJqN1faeudug== -----END CERTIFICATE----- Signed certificate is in newcert.pem
早速、lighttpdに設定して、httpsアクセスできるか、確認してみる。
lighttpd.conf内のSSLに関する部分をファイルの最後尾に追加して、再起動する。
# sudo -u root vi lighttpd.conf $SERVER["socket"] == "182.*.* .*:443" { #### SSL engine ssl.engine = "enable" ssl.pemfile = "/etc/certs/newcert.pem" server.name = "www.*****.***" server.document-root = "/var/www/lighttpd/docs-ssl" } # echo "SSL site" > /var/www/lighttpd/docs-ssl/hoge.txt # service lighttpd restart
ブラウザでhttp://www.******.***/hoge.txt にアクセス。Not foundになる。
続いて、SSLのかかった https://www.*******.***/hoge.txtにアクセス。
悪意のあるサイトかもしれない、と脅されるがアクセスすると見事にアクセスできた。
しかし!Firefoxではアクセスできないことが判明。
うーん、どっかで設定ミスったかなぁ。
一応、以前会社でやったときはうまくいったのになぁ...。
あれこれやってもうまくいかず、いろいろ悩んでしまって面倒くさくなってしまった。
なので、以下の方法で逃げた。
# /etc/pki/tls/certs/make-dummy-cert newcert.pem
なんと、このコマンド一発でオレオレ証明書の発行ができてしまうのである。
うーん、こんなんでいいんだろうか?
今度、落ち着いてゆっくりやろう。
Leave your Comment