Ich versuche, eine Website auf Localhost mit einem selbstsignierten Zertifikat für Express.js auf Windows 10 einzurichten. Hier ist der Express.js-Server-Code.Chrome (net :: ERR_CERT_COMMON_NAME_INVALID) Fehler auf selbstsigniertes SSL-Zertifikat
index.js
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)
Ich habe importiert auch die Zertifizierungsstelle ca.crt Datei zu Chrom und neu gestartet Chrom. Aber ich habe immer noch Fehler auf Chrom, wie unten dargestellt:
Bitte führen, wie dieses Problem zu lösen Dank
Ich habe den Schlüssel und das Zertifikat mit den folgenden Befehlen.
# certificate authority key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out ca.key
# server key
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out server.key
# certificate authority
openssl req -new -x509 -days 365 -key ca.key -subj "/CN=Test CA/O=Test Organization" -out ca.crt
# certificate signing request
openssl req -new -key server.key -subj "/CN=localhost/O=Test Organization" -out server.csr
# server certificate
openssl x509 -days 365 -req -in server.csr -CAcreateserial -CA ca.crt -CAkey ca.key -out server.crt
# verification
openssl verify -verbose -CAfile ca.crt server.crt
System Info
- OpenSSL: 1.1.0e 16. Februar 2017
- Knoten: 7.7.1
- 10 Windows-
Sie könnten hier aussehen wollen [ ] (http://stackoverflow.com/questions/27294589/creating-self-signed-certificate-for-domain-and-subdomains-neterr-cert-commo), scheint es ähnlich zu Ihrem Problem – Frederic
Ihre End-Entität/Server-Zertifikat ist falsch formatiert. *** 'CN = localhost' *** ist falsch. Hostnamen gehen immer in das * SAN *. Wenn es im * CN * vorhanden ist, muss es auch im * SAN * vorhanden sein (in diesem Fall müssen Sie es zweimal auflisten). Weitere Regeln und Gründe finden Sie unter [Wie unterschreiben Sie eine Zertifikatsignierungsanforderung mit Ihrer Zertifizierungsstelle] (http://stackoverflow.com/a/21340898/608639) und [So erstellen Sie ein selbstsigniertes Zertifikat mit openssl?] (http://stackoverflow.com/q/10175812/608639) – jww
@jww CN = Allgemeiner Name, wofür steht SAN? –