-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I generate self signed root CA certificate , and then generate certificates signed by the CA? #13
Comments
Hey, you have to add the keyPari in the options form the generation of the certifact. ` //here you can save the root certifacte and load it, if you need let key_pair = { let attrs_options = { let client_cert = selfsigned.generate(attrs_root, attrs_options);` |
Hello, I try this code, i have const https = require('https')
const app = require('express')()
const selfsigned = require('selfsigned')
const fs = require('fs-extra')
if (!fs.pathExistsSync('./root.json')) {
const rootCA = selfsigned.generate(
[{ name: 'commonName', value: 'titi.devel' }],
{
keySize: 2048,
algorithm: 'sha256'
}
)
fs.writeFileSync('./root.json', JSON.stringify(rootCA, null, 2))
// save rootCA.cert and add it in chrome://settings/certificates Autority
fs.writeFileSync('./root.crt', rootCA.cert)
}
const rootCA = require('./root.json')
const cert = selfsigned.generate(
[{ name: 'commonName', value: 'titi.devel' }],
{
keySize: 2048,
keyPair: {
privateKey: rootCA.private,
publicKey: rootCA.public
},
algorithm: 'sha256'
}
)
app.get('/', (req, res) => res.send('ok'))
const httpsServer = https.createServer(
{
key: cert.private,
cert: cert.cert
},
app
)
httpsServer.listen(443) After add root cert in chrome autority, when i go to https://titi.devel (got to my localhost), i have a certificat not trust error : When open certificat, titi.devel is here : When I make it with openssl, it work fine, but i want auto generate certificate with nodejs for many domain... What did I not understand ? Thank you for you'r help |
Hey, i did not test it, but in my oppinion you need the following params: clientCertificate: true can you try it and give a response? |
Hello, Thank you for you're response. I have found the solution, it's because the Issuer attribute is the same of Subject attribute : I directly use node-forge for generate my certificate, it's work fine (the selfsigned code very help me for use node-forge plugin ;) ) |
Folks, please try #43 which implements certificate generation signed by your own CA. |
thanks a lot for that , I dont know much about how certificates work.
The text was updated successfully, but these errors were encountered: