該證書并非來自可信的授權中心–解決辦法
自從把博客空間搬到MediaTemple(往后簡稱MT主機),全站SSL加密后安卓手機訪問本博客時總時顯示“該證書并非來自可信的授權中心”和Firefox瀏覽器總是顯示“sec_error_unknown_issuer”警告,然而在IE/Chrome/Safari上都顯示非常正常,到底那里出了問題呢?
曾經MT主機客服發過郵件,得到的回復是:
Thank you for contacting (mt) Media Temple!
I have checked the status of the SSL installation and I can confirm it has been installed and working correctly.
That being said, as this SSL was not provided by us we are unable to provide troubleshooting for any issues that arise from 3rd party SSLs. You should contact the SSL provider in regarding to this issue. As a courtesy I have done a bit of research and found that the problem may be because no Issuer Chain was provided or you did not install it. Please bring this information to your SSL provider for help on what should be done.
后來又重新幾次布署SSL,問題依舊。今天終于忍不住向Comodo發現支持請求,得到的回復是:
You may get this error message due to the CA Certificates (Intermediates) were not properly imported on the server.
It shows as follows
——————————————————————–
Trusted by Microsoft? Yes
Trusted by Mozilla? No (unable to get local issuer certificate) UNTRUSTED
——————————————————————–
This can be fixed by importing a proper CA Certificate bundle on your host. Please find the CA-Bundle file from the attachment and upload it on your host to fix this issued.
Please let us know if you need any further assistance.
附件附上“ca-bundle”證書。按以往的經驗在MT主機后臺中導入相應證書,但是發現還是不行。問題依舊,問題到底出現在那里呢?后來在Comodo支持文檔中找到“Certificate Installation: Apache & mod_ssl”這篇文章。里內有一段內容如下:
In the VirtualHost section of the file please add these directives if they do not exist. It is best to comment out what is already there and add the below entries.
SSLEngine on
SSLCertificateKeyFile /etc/ssl/ssl.key/server.key
SSLCertificateFile /etc/ssl/ssl.crt/yourDomainName.crt
SSLCertificateChainFile /etc/ssl/ssl.crt/yourDomainName.ca-bundle ***
這個時候突然想到在MT主機上是有一個etc目錄,但里面只有一個php.ini文件,根本沒有SSL和SSL.CRT目錄,根據以往使用國外主機的經驗,馬上在etc目錄中建立ssl目錄,再在ssl目錄中建立好ssl.crt目的,然后根據上面內容所提示,把yourDomainName.crt和yourDomainName.ca-bundle放進其中。
然后再工具測試:Trusted by Mozilla:Yes。然后借臺安卓手機訪問,嘿,也沒有在顯示“該證書并非來自可信的授權中心”,原來SSL證書不可信問題就是出現在此。記錄本文,希望給大家一些思路,在MT主機CP中設置SSL除了導入證書外,還需要以上這一步。
后補:
再經測試,你在MT后臺導入證書時,把yourDomainName.ca-bundle所以內容放進“CA/Chain Certificate”選項中,也相當于上面的這樣操作。我建議選擇把yourDomainName.ca-bundle所以內容放進“CA/Chain Certificate”選項中。也就是把當初提供給我們的證書AddTrustExternalCARoot.crt、COMODORSAAddTrustCA.crt、COMODORSADomainValidationSecureServerCA.crt證書所有內容匯總后全放進“CA/Chain Certificate”選項中。
https配置CA證書安裝教程
下載得到的 www.domain.com.zip 文件,解壓獲得3個文件夾,分別是Apache、IIS、Nginx 服務器的證書文件,
下面提供了4類服務器證書安裝方法的示例:
1. Apache 2.x 證書部署
1.1 獲取證書
Apache文件夾內獲得證書文件 1_root_bundle.crt,2_www.domain.com_cert.crt 和私鑰文件 3_www.domain.com.key,
1_root_bundle.crt 文件包括一段證書代碼 “-----BEGIN CERTIFICATE-----”和“-----END CERTIFICATE-----”,
2_www.domain.com_cert.crt 文件包括一段證書代碼 “-----BEGIN CERTIFICATE-----”和“-----END CERTIFICATE-----”,
3_www.domain.com.key 文件包括一段私鑰代碼“-----BEGIN RSA PRIVATE KEY-----”和“-----END RSA PRIVATE KEY-----”。
1.2 證書安裝
編輯Apache根目錄下 conf/httpd.conf 文件,
找到 #LoadModule ssl_module modules/mod_ssl.so
和 #Include conf/extra/httpd-ssl.conf
,去掉前面的#
號注釋;
編輯Apache根目錄下 conf/extra/httpd-ssl.conf 文件,修改如下內容:
<VirtualHost www.domain.com:443> DocumentRoot "/var/www/html" ServerName www.domain.com SSLEngine on SSLCertificateFile /usr/local/apache/conf/2_www.domain.com_cert.crt SSLCertificateKeyFile /usr/local/apache/conf/3_www.domain.com.key SSLCertificateChainFile /usr/local/apache/conf/1_root_bundle.crt</VirtualHost>
配置完成后,重新啟動 Apache 就可以使用https://www.domain.com
來訪問了。
注:
配置文件參數 | 說明 |
---|---|
SSLEngine on | 啟用SSL功能 |
SSLCertificateFile | 證書文件 |
SSLCertificateKeyFile | 私鑰文件 |
SSLCertificateChainFile | 證書鏈文件 |
2. Nginx 證書部署
2.1 獲取證書
Nginx文件夾內獲得SSL證書文件 1_www.domain.com_bundle.crt 和私鑰文件 2_www.domain.com.key,
1_www.domain.com_bundle.crt 文件包括兩段證書代碼 “-----BEGIN CERTIFICATE-----”和“-----END CERTIFICATE-----”,
2_www.domain.com.key 文件包括一段私鑰代碼“-----BEGIN RSA PRIVATE KEY-----”和“-----END RSA PRIVATE KEY-----”。
2.2 證書安裝
將域名 www.domain.com 的證書文件1_www.domain.com_bundle.crt 、私鑰文件2_www.domain.com.key保存到同一個目錄,例如/usr/local/nginx/conf目錄下。
更新Nginx根目錄下 conf/nginx.conf 文件如下:
server { listen 443; server_name www.domain.com; #填寫綁定證書的域名 ssl on; ssl_certificate 1_www.domain.com_bundle.crt; ssl_certificate_key 2_www.domain.com.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照這個協議配置 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照這個套件配置 ssl_prefer_server_ciphers on; location / { root html; #站點目錄 index index.html index.htm; } }
配置完成后,先用bin/nginx –t
來測試下配置是否有誤,正確無誤的話,重啟nginx。就可以使 https://www.domain.com
來訪問了。
注:
配置文件參數 | 說明 |
---|---|
listen 443 | SSL訪問端口號為443 |
ssl on | 啟用SSL功能 |
ssl_certificate | 證書文件 |
ssl_certificate_key | 私鑰文件 |
ssl_protocols | 使用的協議 |
ssl_ciphers | 配置加密套件,寫法遵循openssl標準 |
2.3 使用全站加密,http自動跳轉https(可選)
對于用戶不知道網站可以進行https訪問的情況下,讓服務器自動把http的請求重定向到https。
在服務器這邊的話配置的話,可以在頁面里加js腳本,也可以在后端程序里寫重定向,當然也可以在web服務器來實現跳轉。Nginx是支持rewrite的(只要在編譯的時候沒有去掉pcre)
在http的server里增加rewrite ^(.*) https://$host$1 permanent;
這樣就可以實現80進來的請求,重定向為https了。
3. IIS 證書部署
3.1 獲取證書
IIS文件夾內獲得SSL證書文件 www.domain.com.pfx。
3.2 證書安裝
1、打開IIS服務管理器,點擊計算機名稱,雙擊‘服務器證書’
2、雙擊打開服務器證書后,點擊右則的導入
3、選擇證書文件,如果輸入申請證書時有填寫私鑰密碼需要輸入密碼,否則輸入文件夾中密碼文件keystorePass.txt的密碼內容,點擊確定。參考私鑰密碼指引
4、點擊網站下的站點名稱,點擊右則的綁定
5、打開網站綁定界面后,點擊添加
6、添加網站綁定內容:選擇類型為https,端口443和指定對應的SSL證書,點擊確定
7、添加完成后,網站綁定界面將會看到剛剛添加的內容
4. Tomcat 證書部署
4.1 獲取證書
如果申請證書時有填寫私鑰密碼,下載可獲得Tomcat文件夾,其中有密鑰庫 www.domain.com.jks;
如果沒有填寫私鑰密碼,證書下載包的Tomcat文件夾中包括密鑰庫文件www.domain.com.jks 與密鑰庫密碼文件keystorePass.txt
當用戶選擇粘貼CSR時,不提供Tomcat證書文件的下載,需要用戶手動轉換格式生成,操作方法如下:
可以通過 Nginx 文件夾內證書文件和私鑰文件生成jks格式證書
轉換工具:https://www.trustasia.com/tools/cert-converter.htm
使用工具時注意填寫 密鑰庫密碼 ,安裝證書時配置文件中需要填寫。
4.2 證書安裝
配置SSL連接器,將www.domain.com.jks
文件存放到conf目錄下,然后配置同目錄下的server.xml
文件:
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="conf/www.domain.com.jks" keystorePass="changeit" clientAuth="false" sslProtocol="TLS" />
注:
配置文件參數 | 說明 |
---|---|
clientAuth | 如果設為true,表示Tomcat要求所有的SSL客戶出示安全證書,對SSL客戶進行身份驗證 |
keystoreFile | 指定keystore文件的存放位置,可以指定絕對路徑,也可以指定相對于 (Tomcat安裝目錄)環境變量的相對路徑。如果此項沒有設定,默認情況下,Tomcat將從當前操作系統用戶的用戶目錄下讀取名為 “.keystore”的文件。 |
keystorePass | 密鑰庫密碼,指定keystore的密碼。(如果申請證書時有填寫私鑰密碼,密鑰庫密碼即私鑰密碼,否則填寫密鑰庫密碼文件中的密碼) |
sslProtocol | 指定套接字(Socket)使用的加密/解密協議,默認值為TLS |
4.3 http自動跳轉https的安全配置
到conf目錄下的web.xml。在</welcome-file-list>
后面,</web-app>
,也就是倒數第二段里,加上這樣一段
<login-config> <!-- Authorization setting for SSL --> <auth-method>CLIENT-CERT</auth-method> <realm-name>Client Cert Users-only Area</realm-name> </login-config> <security-constraint> <!-- Authorization setting for SSL --> <web-resource-collection> <web-resource-name>SSL</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
這步目的是讓非ssl的connector跳轉到ssl的connector去。所以還需要前往server.xml進行配置:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
redirectPort改成ssl的connector的端口443,重啟后便會生效。
</article>
使用crt和ca-bundle文件給網站配置ssl證書教程
說明:之前看到namecheap
搞的免費換一年Comodo ssl
證書活動,就去搞了一年,申請下來的證書文件就ca-bundle
和crt
文件,習慣用crt
和key
文件來配置ssl
證書的我,就直接無視了ca-bundle
文件,估計很多人也會和我一樣,于是用crt
文件和之前生成的key
文件配置ssl
后,會發現有的瀏覽器提示不安全,查了下問題后,發現證書鏈不完整導致的,感覺不能忽視ca-bundle
文件,就胡亂折騰,最后給整好了。這里把方法分享下。
首先需要將頒發的crt
和ca-bundle
文件合并成一個新crt
文件,登錄vps
運行命令:
cat xxx.crt xxx.ca-bundle > new.crt #crt和ca-bundle文件位置填對
然后用新的crt
做證書文件,key
還是用之前生成的!
配置ssl
具體方法可以參考:可以自行百度
以上轉自:https://www.jinbo123.com/6016.html
https://blog.csdn.net/veloi/article/details/78551349
https://www.moerats.com/archives/164/
總結:我遇到的問題是nginx443端口加密域名www.wangshuai.tech,但是配置了域名crt和key,像一下360和谷歌訪問一切正常。但是手機瀏覽器和火狐瀏覽器打開提示不信任證書。我這的做法是把根證書追加到域名證書文件下面,一切不變。其它就不提示不受信任證書問題了。遇到這個問題,找了一堆文章,上面三篇有起到作用,特此粘貼,希望遇到同樣問題的道友,可以很方便,謝謝。