https単純構成


SSLセッションプロセス
(1)クライアントは選択可能な暗号化方式を送信し,サーバに証明書を要求する.
(2)サーバ側が証明書を送信し,選択した暗号化方式をクライアントに送信する.
(3)クライアントは証明書を取得し、証明書の検証を行う.
新人が証明書を発行したCAの場合.
(a)証明書の出所の合法性を検証する.CAの公開鍵で証明書上のデジタル署名を復号する.
(b)証明書の内容の合法性を検証する.整合性の検証
(c)証明書の有効期限を検査し、期限が切れているかどうかを検査する.
(d)証明書が取り消されたかどうかを検査する.
(e)証明書の所有者の名前は、アクセスするターゲットホストと一致する.
(4)クライアントは一時セッション鍵(対称鍵)を生成し、サーバ側の公開鍵を用いてこのデータを暗号化してサーバに送信し、鍵交換を完了する.
(5)サーバは、この鍵を用いてユーザが要求したリソースを暗号化し、クライアントに応答する.
なお、SSLセッションはIPアドレスに基づいて作成される.したがって、単一IPのホストでは、https仮想ホストは1つしか使用できません.
構成プロセス:
(1)サーバにデジタル証明書を申請する.一般的には私建CAを使って証明書を発行します
(a)172.16.0.244にプライベートCAを作成する
1、生産鍵ペア、秘密鍵を作成し、公開鍵は処理する必要がない
[root@localhost CA]# (umask 077;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
..........+++
..............+++
e is 65537 (0x10001)
[root@localhost CA]#

2、自己署名証明書の生成
[root@localhost CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3655
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]:CN            //              ,      
State or Province Name (full name) []:Beijing   //          http         
Locality Name (eg, city) [Default City]:Beijing //       ,      CA
Organization Name (eg, company) [Default Company Ltd]:Gump Ltd 
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:ca.gump.com
Email Address []:[email protected]  
[root@localhost CA]#

3、証明書に署名する前に、手動で2つのファイルを作成する必要があります.詳細はopenssl編を参照してください.
[root@localhost CA]# touch /etc/pki/CA/index.txt
[root@localhost CA]# touch /etc/pki/CA/serial
[root@localhost CA]# echo 01 > /etc/pki/CA/serial

(2)httpサーバ172.16.0.242上で証明書要求を生成する
(a)様は鍵を作成し、この証明書を適用するサービスのプロファイルディレクトリの下に保存し、httpsセッションの確立およびデータ転送中に、この鍵を使用する必要があります.
[root@localhost ~]# mkdir /etc/httpd/ssl
[root@localhost ~]# cd /etc/httpd/ssl
[root@localhost ssl]# (umask 077;openssl genrsa -out httpd.key 1024)
Generating RSA private key, 1024 bit long modulus
.......++++++
..........++++++
e is 65537 (0x10001)
[root@localhost ssl]#

(b)鍵による証明書申請要求の生成
[root@localhost ssl]# openssl req -new -key httpd.key -out httpd.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]:CN
State or Province Name (full name) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:Gump Ltd
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:web1.gump.com
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:                          //                   
An optional company name []:                      //     
[root@localhost ssl]#

鍵と証明書リクエストは、以前に作成した/etc/http/ssl/ディレクトリの下に保存されていることがわかります.
[root@localhost ssl]# pwd
/etc/httpd/ssl
[root@localhost ssl]# ls
httpd.csr  httpd.key
[root@localhost ssl]#

(3)httpサーバ172.16.2.0.242上の証明書申請要求をCAサーバ172.16.2.0.244上の証明書署名完了に送信する
172.16.20.242:
[root@localhost ssl]# scp httpd.csr [email protected]:/tmp/
The authenticity of host '172.16.20.244 (172.16.20.244)' can't be established.
ECDSA key fingerprint is bc:9c:21:b5:a6:4d:ef:b6:f3:00:94:80:b4:7f:18:f5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.20.244' (ECDSA) to the list of known hosts.
[email protected]'s password: 
httpd.csr                                                                                          100%  696     0.7KB/s   00:00    
[root@localhost ssl]#

172.16.20.244:
[root@localhost CA]# openssl ca -in /tmp/httpd.csr -out certs/web1.gump.com.crt -days 365
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Aug 21 13:20:11 2017 GMT
            Not After : Aug 21 13:20:11 2018 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = Beijing
            organizationName          = Gump Ltd
            organizationalUnitName    = Ops
            commonName                = web1.gump.com
            emailAddress              = [email protected]
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                23:C2:7E:52:B5:AB:E8:A1:06:53:38:7A:39:F0:EB:E3:1C:B3:1F:76
            X509v3 Authority Key Identifier: 
                keyid:EB:31:34:C3:C5:7C:E4:BB:EE:C3:7C:11:5E:F1:70:5C:88:E5:87:D8

Certificate is to be certified until Aug 21 13:20:11 2018 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
[root@localhost CA]#

(4)完了した証明書web 1に署名する.gump.com.crtはhttpサーバ172.16.0.242に転送される
[root@localhost CA]# scp certs/web1.gump.com.crt [email protected]:/etc/httpd/ssl/
The authenticity of host '172.16.20.242 (172.16.20.242)' can't be established.
RSA key fingerprint is 5a:10:33:a2:bf:5b:06:82:25:01:fb:c2:74:93:34:95.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.20.242' (RSA) to the list of known hosts.
[email protected]'s password: 
web1.gump.com.crt                                                                                  100% 3858     3.8KB/s   00:00    
[root@localhost CA]#

(5)sslモジュールのインストール
[root@localhost CA]# yum install mod_ssl -y

(6)sslファイル/etc/http/conf.d/sslを構成する.conf
一般的には、次の構成項目を変更する必要があります.
DocumentRoot//ルート、必要とhttpd.confのルートパスが一致する
Server Name//サーバ名、署名した証明書のサーバ名と一致する必要がある
SSLCertfifcateFile//証明書ファイル格納ディレクトリ
SSLCertificateKeyFile//鍵ファイル格納ディレクトリ
仮想ホストに適用する場合は、次の構成を変更する必要があります.
ここでのdefaultはデフォルト仮想ホストのIPアドレスであり,SSLセッションはIPアドレスに基づいて作成されるため,複数のアドレスがあり,デフォルトアドレスを記入する必要がある.
[root@localhost CA]# vim /etc/httpd/conf.d/ssl.conf
DocumentRoot /www/htdocs
ServerName web1.gump.com
SSLCertificateFile /etc/httpd/ssl/web1.gump.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key

(7)構成が完了するとhttpプロファイルを再ロードする必要がありますが、新しいsslモジュールは動的にロードされ、サービスを再起動することなく有効になります.
構成効果のテスト
# openssl s_client [-connect host:port] [-cert filename] [-CApath directory] [-CAfile filename]
                                                CA             CA     
[root@localhost CA]# openssl s_client -connect 172.16.20.244:443 -CApath /etc/pki/CA/casert.pem

ブラウザ側で直接テストして、ブラウザのアドレスバーに入力することもできます.https://172.16.20.242、正常にアクセスできる場合は、構成が成功したことを示します.
書くのが比較的に乱雑で、もし誤りと論争の場所を漏らしたら、みんなの批判の指摘と討論を歓迎して、ありがとうございます.