!!!Apache2とOpenSSLでhttpsサーバを立てる
{{category Apache}}
----
OpenSSLで認証局をたてて、
httpsサーバ用の鍵&証明書要求を作成して、
サーバ証明書を作成する手順。
*http://chinmai.net/~osakana/diary/?200302a#05-5
*RSAの鍵長は2048bitで
*CSR作るときに -sha256 する。
*署名するときに -md sha256 する
----
Common Name は deprecated されているので、subjectAltName を設定する。
とりあえずopenssl.cnfの extensions に v3_req を追加。
んで、subjectAltName を [v3_req] と [svr_cert] に配列でてきとーに追加。
-# req_extensions = v3_req # The extensions to add to a certificate request
+req_extensions = v3_req # The extensions to add to a certificate request
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[ svr_cert ]
basicConstraints=CA:FALSE
nsCertType = server
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
nsComment = "OpenSSL Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
subjectAltName = @alt_names
[alt_names]
DNS.1 = chinmai.net
DNS.2 = *.chinmai.net
あとはまぁ
# openssl req -config ./openssl.cnf -nodes -new -newkey rsa:2048 -sha256 -keyout httpsd_key.pem -out httpsd_req.pem
して
# openssl ca -config ./openssl.cnf -extensions svr_cert -md sha256 -out httpsd_cert.pem -infiles httpsd_req.pem
して以下略