[精讚] [會員登入]
11949

[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的記錄檔格式 LogFormat 語法 在APACHE中有定義一些記錄的語法模版 在 /etc/httpd/conf/httpd.conf 中: LogForm

[Centos7] 解決資安的幾個問題 因為資安的關係,接到了一些弱點掃描出現的問題,解決方法做個整理。

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

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

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

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

我有話要說

>>

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

訪客留言

[無留言]

隨機好文

使用Google尋找你的手機 這近發現google竟然可以用來找android的手機,而且不需要經過什麼設定或安裝軟體。

[MAC] 截取螢幕畫面的方法 截取螢幕畫面的方法,在MAC中叫作螢幕快照,英文是screenshot

談借錢 人借錢時手心向上頭向下,人還錢時手心向下頭向上

[HP DL380G7] 生效啟動第3,4片網卡/開啟或關閉內建的網卡 HP DL380G7 預設第3,4片網卡裝完系統後找不到,難道是壞了?要怎麼辦?

UTF-8 BOM (Byte Order Mark) 的問題 在 Michael Kaplan 那看到 Every character has a story #4: U+feff