1.安裝OpenSSL套件
yum install openssl
中途會跳出詢問,回覆”y”
Is this ok [y/N]: y
2.安裝SSL模組到Apache
yum install mod_ssl
中途會跳出詢問,回覆”y”
Is this ok [y/N]: y
3.產生Private Key
openssl genrsa -des3 -out wwwserver.key 2048 // 設定密鑰強度
(openssl genrsa -des3 -out 域名.key 2048)
以下填寫的內容皆輸入英文,並將所有填寫的資料記錄起來(key檔案需要備份),密鑰請不要外流
Enter pass phrase for wwwserver.key:請輸入您的密鑰
Verifying - Enter pass phrase for wwwserver.key: 請再次輸入您的密鑰
4.產生CSR
openssl req -new -key wwwserver.key -out wwwserver.csr //設定CSR檔案
(openssl req -new -key 域名.key -out 域名.csr)
Country Name:國家
State or Province Name:州或省
Locality Name:城市
Organization:公司名稱
Organization Unit Name:部門名稱
Common Name:域名(網站名稱)
例如: domain.com
請注意: 如您購買通用型憑證,請在此輸入*.域名.com
Email Address []:管理員電子郵件(完整email)
A challenge Password:請按鍵盤上的enter 鍵略過
Optional company name: 請按鍵盤上的enter 鍵略過
輸入ls,查看剛創建的檔案位置
請將CSR檔提供給購買的憑證廠商(FTP方式下載)
安裝憑證
1. 將CSR移至 /etc/pki/tls/certs 目錄、Private Key移至 /etc/pki/tls/private 目錄
mv wwwserver.csr /etc/pki/tls/certs
mv wwwserver.key /etc/pki/tls/private
憑證廠商提供的證書壓縮檔解壓縮後,裡面有主要憑證(域名.crt)及中繼憑證(除了主要憑證,其他都是ca憑證)
2.將其他證書合併成中繼憑證(請使用記事本,按照順序貼上,排列順序請詢問購買的憑證商,這裡順序是USERTrust_RSA_Certification_Authority.crt在前,AAA_Certificate_Services.crt在後,貼文一份換行繼續貼上),另存新檔為wwwserver -ca-bundle.crt
3.把主要憑證及中繼憑證儲存至 /etc/pki/tls/certs 目錄(FTP方式上傳)
4.編輯 /etc/httpd/conf.d/ssl.conf 修改為下列資訊後儲存
<VirtualHost 虛擬伺服器的IP>
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/wwwserver.crt //憑證檔案路徑
SSLCertificateKeyFile /etc/pki/tls/private/wwwserver.key //私鑰檔案路徑
SSLCACertificateFile /etc/pki/tls/certs/wwwserver-ca-bundle.crt //中繼憑證檔案路徑
</VirtualHost>
5.請重新開啟 Apache 伺服器。
service httpd restart
Enter TLS private key passphrase for 域名.com:443 (RSA) : 密鑰密碼