[精讚] [會員登入]
11941

[HTTPS] Ubuntu +SSL +正式的CA 設定

利用正式的CA憑證,設定網站SSL,有別於過去使用的「未授權憑證」

分享此文連結 //n.sfs.tw/10939

分享連結 [HTTPS] Ubuntu +SSL +正式的CA 設定@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-10-25 11:52:56 最後編修
2017-03-26 02:52:22 By 張○○
 

自動目錄

這近要替台中市教育局的網站設定 SSL,有別於過去使用的「假憑證」,我們申請正式的憑證。

OS

# uname -a
Linux tc-server 2.6.35-22-generic-pae #35-Ubuntu SMP Sat Oct 16 22:16:51 UTC 2010 i686 GNU/Linux

1. 產生主機的key 和csr申請檔

產生私密金鑰 (Private Key)
  # openssl genrsa -out server.key 2048
產生憑證申請檔 (Certificate Signing Request)
  # openssl req -new -key ./server.key -out server.csr

下面是填具的資料:

Country Name (2 letter code) [AU]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Taichung
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Education Bureau, Taichung City Government
Organizational Unit Name (eg, section) []:center
Common Name (eg, YOUR name) []:www.tc.edu.tw
Email Address []:.

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:.
An optional company name []:.

這時會產生兩個檔案 server.key, server.csr ,請把這兩個檔案給認證機構服務商

2. 將憑證檔放到伺服器中

將認證機構回傳的三個檔案及步驟1產生的兩個檔放到伺服器中,此例放到 /etc/ssl/private:

server.key  (私鑰)
server.csr  (憑證申請檔,用不到)
AddTrustExternalCARoot.crt (根憑證Root CA certificate,應該也用不到)
UTNAddTrustServerCA.crt (中繼憑證 Chain CA certificate)
domain.name.crt (網站伺服器憑證Web certificate)

3. 修改HTTP conf

# vi /etc/apache2/portsconf 

NameVirtualHost *:80
Listen 80  # 保持原狀,不必特別 Listen 443

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

4. 修改 /etc/apache2/sites-available/default-ssl

修改內容(紅色字為異動內容):
<VirtualHost _default_:443>
 ....
  SSLEngine on
# Axer 修改start 1000301
SSLCertificateFile /etc/ssl/private/domain.name.crt
SSLCertificateKeyFile /etc/ssl/private/server.key
SSLCertificateChainFile /etc/ssl/private/UTNAddTrustServerCA.crt

  ....
</VirtualHost>

5. 加入軟連結

# cd /etc/apache2/sites-available/
# ln -s ../sites-available/default-ssl ssl

重啟 apache 即可,如果失敗,可以試試步驟6。

6. 啟動 ssl module

啟用 ssl 模組
a2enmod ssl
啟用 ssl 虛擬站台
a2ensite default-ssl
安裝 ssl 套件
apt-get install openssl ssl-cert
重啟 apache
/etc/init.d/apache2 restart

如果出現這樣的錯誤 SSL 收到含超出最大允許字串長度的記錄。
(錯誤碼: ssl_error_rx_record_too_long)

我的經驗是 SSL 設定錯誤,請檢查 /etc/apache2/sites-available/default-ssl 和軟連結是否有正確設定。

參考資料

[1] 產生一張 SSL 電子證書 http://wiki.debian.org.hk/w/Generate_SSL_cert

[2] Apache 2 with SSL/TLS: Step-by-Step, Part 1http://www.symantec.com/connect/articles/apache-2-ssltls-step-step-part-1


原文 2011-03-02 14:05:18

END

你可能感興趣的文章

[Apache] 顯示或不顯示錯誤 php預設錯誤不顯示,有三種方法可以顯示或不顯示錯誤

[HTTPS] Ubuntu +SSL +正式的CA 設定 利用正式的CA憑證,設定網站SSL,有別於過去使用的「未授權憑證」

[APACHE] 關於RewriteCond $1 RewriteCond $1的意義和解釋

UTF-8的網頁但IE8一片空白 UTF8編碼的網頁在Firefox 正常顯示、但IE8 就是空白,IE8編碼設定是「自動偵測」可是自動偵測到的是 big5...

[Apache] 利用.htaccess防盜圖 利用.htaccess防盜圖,同時也介紹一個產生防盜圖.htaccess檔的網站

[APACHE] Centos7,8設定 HSTS ( HTTP Strict Transport Security ) CENTOS7,CENTOS8 資安上需要設定的 HSTS的方法。

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[Windows7] 移除IE10及移除IE11 Windows7 不得已的情況要移除IE11或IE10怎麼做?

看懂DSUB DVI HDMI USB等各式影音接頭 看懂DSUB DVI HDMI等各式影音接頭

[bc] linux 的計算機 bc 設定小數位數、計算π、次方根 linux 的計算機 bc 設定小數位數、計算π、次方根

[CodeIgniter3] 解決無法上傳特定檔案(.sb2)的問題 上傳時出現The filetype you are attempting to upload is not allowed,要怎麼解決?

[PHP] 檢查檔案是否是圖檔 使用getimagesize函數檢查檔案是否是圖檔