2017-09-11 22 views
2

我跟着this page創建我的SSL證書。
而我已經使用openssl創建rootCA和服務器證書。鉻不信任HTTPS和顯示ERR_SSL_SERVER_CERT_BAD_FORMAT

但在鉻它顯示此頁。 image here
Openssl的命令是由該遵循:

"[Apache install path]\bin" openssl genrsa -des3 -out rootCA.key 2048 
"[Apache install path]\bin" openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3560 -extensions v3_req -out rootCA.pem 

Country Name (2 letter code) [AU]:TW 
State or Province Name (full name) [Some-State]:Taiwan 
Locality Name (eg, city) []:Taipei 
Organization Name (eg, company) [Internet Widgits Pty Ltd]:CR 
Organizational Unit Name (eg, section) []:IT section 
Common Name (eg, server FQDN or YOUR name) []:localhost 
Email Address []:[email protected] 

並安裝rootCA.pem到OS可信證書(我的操作系統是Windows 10)
然後生成CSR:

set OPENSSL_CONF=[Apache install path]\conf\openssl.cnf (This is apache default) 
openssl genrsa -out server.key 2048 

通用名稱與rootCA不同,後者設置爲「html_12」。

openssl req -new -key server.key -out server.csr 
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.crt -days 500 -sha256 -extensions v3_req 

而在的httpd-ssl.conf中的Apache設置:

SSLCertificateFile "D:/xampp/Apache2.2_win32/conf/server.crt" 
SSLCertificateKeyFile "D:/xampp/Apache2.2_win32/conf/server.key" 

在的httpd-vhosts.conf是一樣的:

<VirtualHost *:80> 
    DocumentRoot "E:/PHP_TEST" 
    ServerName html_12 
    ErrorLog "logs/html_12M-error.log" 
    CustomLog "logs/html_12M-access.log" common 
    SSLEngine on 
    SSLProtocol all -SSLv2 
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 
    SSLCertificateFile "D:/xampp/Apache2.2_win32/conf/server.crt" 
    SSLCertificateKeyFile "D:/xampp/Apache2.2_win32/conf/server.key" 
    SSLCACertificateFile "D:/xampp/Apache2.2_win32/conf/rootCA.pem" 
</VirtualHost> 

這是更新後的Chrome發生61.0 .3163.79,我不知道這是否與Chrome有關。

之前,我更新,它只是顯示「您的連接不是私有的」,我可以點擊「前進」繼續我的工作。

我也在設置chrome://flags/#allow-insecure-localhost,允許從localhost加載資源的無效證書。 啓用
但仍然有同樣的問題。

我可以做任何其他信任我的本地主機證書嗎?

回答

1

我必須解決這個問題。

我要創建在同一個根文件v3.ext與OpenSSL的。

文件內容:

[req] 
distinguished_name = req_distinguished_name 
x509_extensions = v3_req 
prompt = no 
[req_distinguished_name] 
C = TW 
ST = Taiwan 
L = Taipei 
O = CR 
OU = It 
CN = html_12 
[v3_req] 
keyUsage = keyEncipherment, dataEncipherment 
extendedKeyUsage = serverAuth 
subjectAltName = @alt_names 
[alt_names] 
DNS.1=html_12 

然後執行命令行生成關鍵 & CRT文件:

openssl req -new -newkey rsa:2048 -sha256 -days 3650 -nodes -x509 -keyout server.key -out server.crt -config v3.ext -extensions v3_req

然後把文件中的Apache。
它的工作原理。

0

如果您有原始的.csr和原證書的私鑰則只能通過改變openssl.conf

解決它您將其添加到文件:

[alt_names] 
DNS.1=html_12 

...並且可以再次生成證書:

openssl x509 -signkey private.key -in request.csr -req -days 365 -out cert-newcert.cer