| |
|
|
| ◆ |
mod_ssl のインストール |
|
|
|
[root@centos]#
yum -y install mod_ssl
<--- 入力
|
|
|
|
|
|
◆
|
認証キーの作成
|
|
|
|
|
|
SSL通信の正当性を認証してくれる公の正規認証局から発行される証明書をWebサーバに置いておくことが必要になる
しかし、正規認証局にサーバを認証してもらうには認証局と契約をしなければな
らないし費用もかなり掛かるので自分で認証し証明書を発行する
サーバー用シークレット認証キーの作成
|
|
|
|
|
|
[root@centos]#
cd /etc/pki/tls/certs
<---
certs ディレクトリに移動
[root@fedora
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:
******
<--- 再度パスワード入力(* は実際には表示されません)
|
|
|
|
|
Webサーバー起動時にパスワードを要求されないようにするためにサーバー用シークレット認証キーのパスワードを削除
|
|
|
|
|
|
[root@centos
certs]#
openssl rsa -in server.key -out server.key
<--- 入力
Enter pass phrase for server.key:
******
<--- パスワード入力(* は実際には表示されません)
writing RSA key
|
|
|
|
|
サーバー用公開認証キーの作成
|
|
|
|
|
|
[root@centos
certs]#
make server.csr
<--- 入力
umask 77 ; \
/usr/bin/openssl req -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) []:Tokyou
<--- 都道府県名入力
Locality Name (eg, city) [Default City]:tiyoda-ku
<--- 市区町村名入力
はサーバー名)
Organization Name (eg, company) [Default Company Ltd]:linux-server
<--- 会社名入力(個人運営の場合↑
Organizational Unit Name (eg, section) []:
<--- 部署名入力(個人運営の場合は空白のまま Enter を押す)
Common Name (eg, your name or your server's hostname) []:www.papa-net.info
<---
ドメイン名入力
Email Address []:****@xxxx.zzz
<--- サーバー管理者のメールアドレス入力
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
<--- 空白のまま Enter を押す
An optional company name []:
<--- 空白のまま Enter を押す
|
|
|
|
|
サーバー用証明書の作成
|
|
|
|
|
|
[root@centos
certs]#
openssl x509 -in server.csr -out server.crt
-req -signkey server.key -days 3650
Signature ok
↑サーバー用証明書作成
subject=/C=JP/ST=Tokyou/L=tiyoda-ku/O=papa-net/CN=papa-net/emailAddress=****@xxxx.zzz
<--- 左記のよう
Getting Private
key
に上で入力した内容が表示されれば完了
|
|
|
|
|
|
尚、上記設定は3650日(10年間)有効なので設定日より365日経過した場合は再度設定が必要 |
|
最後の数字(365)は日数を表しますのでこの数字を変えることで有効期間を変えることができる |
|
|
|
|
rootのみが
SSL の内容を参照できるようにアクセス権を変更
|
|
|
|
|
|
[root@centos
certs]#
chmod 400 /etc/pki/tls/certs
<---
入力
You have new mail in /var/spool/mail/root
|
|
|
|
|
|
◆
|
SSL
の設定
|
|
|
|
|
|
WebブラウザでSSL通信でなければ閲覧できないページを作成する場合に設定 |
|
|
|
|
|
[root@centos]#
vi /etc/httpd/conf.d/ssl.conf
<--- 入力
途中略
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
<--- コメント解除して書き換え
↓
(ドキュメントルート(ホームぺージファイルの格納フォルダ)の指定)
DocumentRoot "/home/user/www/ssl"
※指定しない(どこでも利用できるようにする)場合は変更なし
#ServerName
www.example.com:443
<--- コメント解除して書き換え
↓
ServerName
www.papa-net.info:443
途中略
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
<--- 認証キーファイルの指定
↓
SSLCertificateFile
/etc/pki/tls/certs/server.crt
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
<--- 認証キーファイルの指定
↓
SSLCertificateKeyFile
/etc/pki/tls/certs/server.key
以下略
|
|
|
|
|
|
◆
|
apacheの再読込
|
|
|
|
|
|
[root@centos]#
/etc/rc.d/init.d/httpd
reload
<--- 入力
|
|
|
|
|
|
|
|
◆ |
閲覧者への案内 |
|
|
|
|
SSL(https://******.com)でアクセスすると下図のような『セキュリティの警告』
ページが表示される
このページは通常のSSLを利用いたサイトでは表示され
ないが、当サイト(上記の設定)の様な個人が運営するサイトでは高い料金を支払って認証機関に認証してもらい証明書を発行してもらうのは出来ないので自己認証という認証制度を利用しているためこの様なページが表示される
『このサイトの閲覧を続行する(推奨されません)。』をクリックする事により本来のページが表示される
この事をサイト上に案内して閲覧者に理解してもらうようにする

|
|
|
|
|