[精讚] [會員登入]
12070

[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

你可能感興趣的文章

PHP 7.0 升級到 PHP7.3 因為套件的關係,想把PHP7.0升到7.3 結果又退回原版本

強迫網頁預設編碼語系 大部分的瀏覽器如果編碼設成「自動偵測」時都能正確的分析。但世界並不會這麼平順完美,明明我這樣設定utf8他就是用big5丟出來...

[Apache] 自訂錯誤頁面及移掉歡迎頁 Apache 有一個歡迎頁,以正式網站來說,出現這頁有點不專業,該移除它..

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

APACHE的記錄檔格式 LogFormat 語法 在APACHE中有定義一些記錄的語法模版 在 /etc/httpd/conf/httpd.conf 中: LogForm

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

我有話要說

>>

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

訪客留言

[無留言]

隨機好文

SELinux 常用指令和檔案 在Redhat系列中,Centos5以後加入了selinux,他並沒有這麼可怕,不必每次看到Selinux ,就想把他

[PHP] 檢查IP是否在某個網段內 mtachcidr 要檢查IP是否在某個網段內,要寫幾行?10行?5行? 不用,只要2行。以下是我寫的 code /** * matchCI

[CodeIgniter 3] 資料庫的使用方法整理2/2 CI3 承襲 CI2,有很多的builder class可以用,依各人的使用習慣,有人喜歡一堆sql字串,有人喜歡用helper

維修海棉拖把頭 這類型的海棉拖把很好用,可是這近發現海棉頭越來越不耐用,也許是錯覺,以往都能用個三四個月,現在二個月就差不多掉下來。 這

[PHP]解決ksort新增的SORT_NATURAL|SORT_FLAG_CASE方法 php>=5.4中ksort函數多了SORT_NATURAL 和 SORT_FLAG_CASE 旗標,對舊版的PHP中要怎麼辦?