chrome不信任https并显示ERR_SSL_SERVER_CERT_BAD_FORMAT

时间:2017-09-11 09:57:39

标签: apache google-chrome ssl https

我按照this page创建我的SSL证书 我使用openssl创建rootCA和服务器证书。

但在chrome中显示此页面。 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 []:cr@localhost

rootCA.pem 安装到操作系统可信证书。(我的操作系统是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相关。

在我更新之前,只显示&#34;您的连接不是私密的&#34;,我可以点击&#34;提前&#34;继续我的工作。

我还设置了chrome://flags/#allow-insecure-localhost,允许从localhost加载资源的无效证书。 启用
但仍然有同样的问题。

我可以做任何其他信任我的localhost证书吗?

2 个答案:

答案 0 :(得分:1)

我已经解决了这个问题。

我必须使用openssl在同一个根目录中创建一个文件v3.ext
文件内容:

[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

然后执行命令行以生成&amp; 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中 它有效。

答案 1 :(得分: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
相关问题