SSLインストール

いわゆるオレオレ証明書を発行して、通信をSSLにします。
まず、SSL証明書を作成します。
下記ディレクトリに移動して、実行します。
# cd /etc/pki/tls/certs
# make server.key
umask 77 ; \
/usr/bin/openssl genrsa -aes128 2048 > server.key
Generating RSA private key, 2048 bit long modulus
...
...
e is 65537 (0x10001)
Enter pass phrase:(パスフレーズ設定)
Verifying - Enter pass phrase:(再入力)

秘密鍵からパスフレーズを削除します
# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key:(先ほど設定したパスフレーズを入力)
writing RSA key

# make server.csr
umask 77 ; \
/usr/bin/openssl req -utf8 -new -key server.key -out server.csr
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]:Minato(都市)
Organization Name (eg, company) [Default Company Ltd]:PRSL(会社名)
Organizational Unit Name (eg, section) []:PRSL(部署名)
Common Name (eg, your name or your server's hostname) []:lamp(サーバのFQDN)
Email Address []:root@localhost(管理者メールアドレス)

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:(何もせずEnter)
An optional company name []:(何もせずEnter)

有効期限1年の自己証明書を作成
# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 365
Signature ok
subject=/C=JP/ST=Tokyo/L=Minato/O=PRSL/OU=PRSL/CN=lamp/emailAddress=root@localhost
Getting Private key

それでは、SSL通信ができるよう設定します。
mod_sslをインストールします。
# yum -y install mod_ssl

コンフィグファイルを修正します。
# cp -p /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.org
# vi /etc/httpd/conf.d/ssl.conf
59行目 コメントアウト
DocumentRoot "/var/www/html"
60行目 コメント解除しサーバー名指定
ServerName lamp:443
75行目 TSLに変更
SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2
100行目 証明書を指定
SSLCertificateFile /etc/pki/tls/certs/server.crt
107行目 鍵ファイルを指定
SSLCertificateKeyFile /etc/pki/tls/certs/server.key

Apacheを再起動します。
# systemctl restart httpd

クライアントPCからhttpsでアクセスします。下記を入力してください。
https://IPアドレス or Hostname

独自に作成した証明書のため、クライアントにインストールされておらず、以下のような警告が出ますが、例外を許可します。

このように表示されます。