Mac OS Xのhomebrewで入れたapacheにhttpsを適用する
証明書関連作成スクリプト位置
/usr/local/etc/openssl/misc
Opensslの位置
/usr/local/opt/openssl/bin/openssl
(注記:which opensslやると/usr/bin/opensslとかなってたので、↑のパスを直接叩くようにする)
作業ディレクトリへ移動
cd /usr/local/etc/openssl/misc/
CA (認証局) の作成
/usr/local/etc/openssl/misc/CA.sh -newca
CA certificate filename (or enter to create)
空ENTER
Enter PEM pass phrase:パスフレーズ入力
Verifying – Enter PEM pass phrase:パスフレーズ入力
Country Name (2 letter code) [AU]:空ENTER
State or Province Name (full name) [Some-State]:空ENTER
Locality Name (eg, city) []:空ENTER
Organization Name (eg, company) [Internet Widgits Pty Ltd]:空ENTER
Organizational Unit Name (eg, section) []:空ENTER
Common Name (e.g. server FQDN or YOUR name) []:localhost
Email Address []:空ENTER
A challenge password []:空ENTER
An optional company name []:空ENTER
Enter pass phrase for ./demoCA/private/./cakey.pem:パスフレーズ入力
Write out database with 1 new entries
Data Base Updated
と出たら完了
秘密鍵の作成
/usr/local/opt/openssl/bin/openssl genrsa -des3 -out server.key 1024
Enter pass phrase for server.key:パスフレーズ入力
Verifying - Enter pass phrase for server.key:パスフレーズ入力
プロテクトの解除
/usr/local/opt/openssl/bin/openssl rsa -in server.key -out server.key
Enter pass phrase for server.key:パスフレーズ入力
署名要求ファイルの作成
/usr/local/opt/openssl/bin/openssl req -new -days 365 -key server.key -out server.csr
Country Name (2 letter code) [AU]:空ENTER
State or Province Name (full name) [Some-State]:空ENTER
Locality Name (eg, city) []:空ENTER
Organization Name (eg, company) [Internet Widgits Pty Ltd]:空ENTER
Organizational Unit Name (eg, section) []:空ENTER
Common Name (e.g. server FQDN or YOUR name) []:localhost
Email Address []:空ENTER
A challenge password []:空ENTER
An optional company name []:空ENTER
証明書作成
/usr/local/opt/openssl/bin/openssl ca -policy policy_anything -in server.csr -keyfile demoCA/private/cakey.pem -out server.crt
Enter pass phrase for demoCA/private/cakey.pem:パスフレーズ入力
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
もし、
failed to update database
TXT_DB error number 2
というエラーが出たら
rm demoCA/index.txt
touch demoCA/index.txt
を実行してから、
/usr/local/opt/openssl/bin/openssl ca -policy policy_anything -in server.csr -keyfile demoCA/private/cakey.pem -out server.crt
を再実行する
証明書ファイル等をコピーする
cp server.crt /usr/local/etc/apache2/
cp server.key /usr/local/etc/apache2/
httpd.confを修正する
vim /usr/local/etc/apache2/httpd.conf
修正箇所は、下記の行のコメントアウトを外す
#Include /usr/local/etc/apache2/extra/httpd-ssl.conf
Include /usr/local/etc/apache2/extra/httpd-ssl.conf
最後は
apachectl restart
でApacheを再起動させる
コメント
コメントを投稿