SSL自签名证书上的Chrome(net :: ERR_CERT_COMMON_NAME_INVALID)错误

时间:2017-03-15 17:01:28

标签: node.js google-chrome express ssl-certificate

我尝试在Windows 10上使用Express.js的自签名证书在localhost上设置站点。这是Express.js服务器代码。

index.js

python train.py                                                                        
Using Theano backend.                                                                                                     
WARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10).  Please switch to the gpuarray backend. You can get more information about how to switch at this URL:                                                                          
https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29                                                        

ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.

我还将证书颁发机构 ca.crt 文件导入chrome,然后重新启动了chrome。但我仍然在chrome上有错误,如下所示:

enter image description here

请指导如何解决此问题 感谢

我使用以下命令创建了密钥和证书。

const https = require('https')
const express = require('express')
const app = express()
const fs = require('fs')
const path = require('path')

const httpsOptions = {
    cert: fs.readFileSync(path.resolve(__dirname, 'ssl', 'ca.crt')),
    key: fs.readFileSync(path.resolve(__dirname, 'ssl', 'ca.key'))
}

const router = require('./router')

app.use('/people', router)

https.createServer(httpsOptions, app)
    .listen(3443)

系统信息

  • OpenSSL:1.1.0e 2017年2月16日
  • 节点:7.7.1
  • Windows 10

1 个答案:

答案 0 :(得分:6)

花了几个小时试图解决这个问题。以下方式对我有用:

创建配置文件(例如req.cnf)

[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
  [req_distinguished_name]
C = US
ST = VA
L = SomeCity
O = MyCompany
OU = MyDivision
CN = local.com
  [v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
  [alt_names]
DNS.1 = local.com
IP.1 = 127.0.0.1

然后生成证书和私钥

 openssl req -x509 -nodes -days 730 -newkey rsa:2048 -keyout local.com.key -out local.com.cert -config req.cnf -sha256