はじめに
投稿練習も兼ねて、ApacheでSSL利用のために行ったことの備忘録として作成。
前提
CentOS 6.9
Apache 2.2
opensslのインストール
# yum install openssl
mod_sslのインストール
次のコマンドでモジュールがインストールされているか確認。
# httpd -M | grep ssl
入っていない場合、次のコマンドでmod_sslをインストール。
# yum install mod_ssl
インストールの際に /etc/httpd/conf.d/ssl.conf が作成される。
秘密鍵、証明書の作成
# cd /etc/httpd/conf
次のコマンドで秘密鍵を作成。
# openssl genrsa -aes128 1024 > server.key
次のコマンドでCSR(証明書の基となる情報)を作成。
# openssl req -new -key server.key > server.csr
パスフレーズを入力
Enter pass phrase for server.key:
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]:
組織名(空白)
Organization Name (eg, company) [Default Company Ltd]:
部門名(空白)
Organizational Unit Name (eg, section) []:
サーバ名、IPアドレスを入力
Common Name (eg, your name or your server's hostname) []:192.168.56.254
メールアドレス(空白)
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
別のパスワード?(空白)
A challenge password []:
別の組織名(空白)
An optional company name []:
次のコマンドで証明書を作成。
# openssl x509 -in server.csr -days 36500 -req -signkey server.key > server.crt
起動時にパスフレーズの入力を省略
# mv server.key server.key.bak
次のコマンドでパスフレーズを削除。
# openssl rsa -in server.key.bak > server.key
sslの設定ファイル編集
vi /etc/httpd/conf.d/ssl.conf
元ある記述をコメントアウトし、下記を追加
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateFile /etc/httpd/conf/server.crt
SSLCertificateKeyFile /etc/httpd/conf/server.key
Apacheを再起動して完了。
以上