顯示廣告
隱藏 ✕
看板 Knuckles_note
作者 Knuckles (站長 那克斯)
標題 [Linux][CentOS] Apache 設定 SSL (https)加密連線
時間 2012年07月04日 Wed. PM 05:03:26


==============================================================================
改用免費的 Let's Encrypt SSL 憑證
[CentOS7] Apache 使用 Certbot 申請 Let's Encrypt 的SSL憑證 - KnucklesNote板 - Disp BBS
==============================================================================

參考 http://wiki.centos.org/zh-tw/HowTos/Https

安裝 SSL
# yum install mod_ssl openssl


○ 申請 GoDaddy 的 SSL http://community.godaddy.com/help/5269

# cd /etc/pki/tls/private

要用 2048 的 key

產生私鑰
# openssl genrsa -out ca2048.key 2048

利用私鑰產生 csr 申請書
# openssl req -new -key ca2048.key -out ca2048.csr


Country Name (2 letter code) [GB]: TW  ← 國名
State or Province Name (full name) [Berkshire]: Taiwan  ← 省名
Locality Name (eg, city) [Newbury]: Taipei  ← 城市名
Organization Name (eg, company) [My Company Ltd]: Disp  ← 組織名 (任意)
Organizational Unit Name (eg, section) []:  ← 不用輸入
Common Name (eg, your name or your server's hostname) []: disp.cc  ← 要認証的網域名
Email Address []: yourname@yourserver.com   ← E-mail
Please enter the following 'extra' attributes to be sent with your certificate request
A challenge password []:       ← 不用輸入
An optional company name []:   ← 不用輸入


複製 csr 的內容
# vim ca2048.csr
-----BEGIN CERTIFICATE REQUEST-----
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
....
xxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE REQUEST-----


登入 goDaddy 設定 SSL Certificates

依安裝 SSL 步驟設定,在輸入 csr 的地方把上面 csr 的那一串文字貼上

點 download 下載証書
[圖]



下載的檔案解縮後會有
XXXXXXXXXXXXXXXX.crt 與 gd_bundle-XX-XX.crt

將這兩個檔案放至 /etc/pki/tls/certs

修改 apache 的 ssl.conf 檔
# vim /etc/httpd/conf.d/ssl.conf

SSLCertificateFile /etc/pki/tls/certs/XXXXXXXXXXXXXXXX.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca2048.key
SSLCACertificateFile /etc/pki/tls/certs/gd_bundle-XX-XX.crt

修改 apache 的 virtual.conf 檔
# vim /etc/httpd/conf.d/virtual.conf

前面加上 NameVirtualHost *:443

再加上

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/XXXXXXXXXXXXXXXX.crt
    SSLCertificateKeyFile /etc/pki/tls/private/ca2048.key
    SSLCACertificateFile /etc/pki/tls/certs/gd_bundle-XX-XX.crt
    # *:80 的有什麼設定,這邊也要再寫一次
    ServerName   disp.cc
    DocumentRoot /var/www/disp
    <Directory /var/www/disp>
	
# ...
    </Directory>
</VirtualHost>



# 存檔後重啟 apache
# service httpd restart



防火牆設定,修改 iptables 打開 443 port

iptables -A INPUT -p TCP -i $EXTIF --dport 443  -j ACCEPT   # HTTPS





=================問題解決記錄====================
○ 移除金鑰密碼 passphrase

產生金鑰時設密碼的話重開機會有問題 (httpd無法執行?)
且每次重開 httpd 就要輸入一次密碼

移除密碼的方法
openssl rsa -in ca2048.key -out ca2048.key

產生金鑰時不要加 -des3 就不用輸入密碼


○ 使用https時網站無回應

確定防火牆的 443 有沒有打開


◎ GoDaddy SSL證書到期續用

在 GoDaddy 通知快到期後去點了 Renew 並再買了一年後,就不知道要做什麼了
參考: http://support.godaddy.com/help/article/864/renewing-your-ssl-certificate

[圖]
 
原來要到 Credits,點一下 Click here to update your list 後才會跑出東西來....

* 20150615 註: GoDaddy SSL 續用改看這篇 http://disp.cc/b/11-8Lhf

○ 用 Re-Key 產生新的 crt

用新的 private key 產生新的 csr 後
到 Godaddy 點 Re-Key ,輸入新的 csr

注意這邊要記得點 Update List 才會出現新的 crt
要下載新的 crt,如果抓到舊的 apache 會啟動失敗
舊的 crt 72小時後 godaddy 會自動移除

   
--
※ 作者: Knuckles 時間: 2012-07-04 17:03:26
※ 編輯: Knuckles 時間: 2023-11-26 23:53:40 (台灣)
※ 看板: KnucklesNote 文章推薦值: 0 目前人氣: 0 累積人氣: 4504 
分享網址: 複製 已複製
e)編輯 d)刪除 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇