nodejs - wrong self signed certificate in certificate chain


Doyle:

I'm having issues with client side https requests.

Fragments can look like this:

var fs = require('fs');
var https = require('https');

var options = {
    hostname: 'someHostName.com',
    port: 443,
    path: '/path',
    method: 'GET',
    key: fs.readFileSync('key.key'),
    cert: fs.readFileSync('certificate.crt')
}

var requestGet = https.request(options, function(res){
    console.log('resObj', res);
}

What I get is Error: Self-signed certificate in certificate chain.

When using postman, I can import the client certificate and key and use it without issue. Is there any solution available? I would also like to have an idea of ​​how Postman handles certificates and how it works.

Peter Grainger:

From your question, I guess you are developing with a self-signed certificate for SSL communication.

If this is the case, NODE_TLS_REJECT_UNAUTHORIZED='0'use wherever you are running node or directlyNODE_TLS_REJECT_UNAUTHORIZED='0' node app.js

This instructs the node to allow untrusted certificates (untrusted = not verified by a certificate authority)

If you don't want to set an environment variable or need to do this for multiple applications, npm has a configuration that you can set withnpm config set strict-ssl=false

I don't recommend setting this environment variable in production. Use a free SSL certificate from a trusted provider like letsencrypt.org

Related


nodejs - wrong self signed certificate in certificate chain

Doyle: I'm having issues with client side https requests. Fragments can look like this: var fs = require('fs'); var https = require('https'); var options = { hostname: 'someHostName.com', port: 443, path: '/path', method: 'GET', key: fs.re

nodejs - wrong self signed certificate in certificate chain

Doyle: I'm having issues with client side https requests. Fragments can look like this: var fs = require('fs'); var https = require('https'); var options = { hostname: 'someHostName.com', port: 443, path: '/path', method: 'GET', key: fs.re

OpenSSL: Error "Self-signed certificate in certificate chain"

Lunar Mushrooms: When I use the openssl API to verify the server certificate (self-signed), I get the following error: Error 1 Deep Look 19: Self-signed certificate in certificate chain According to the openssl documentation , this error (19) is "X509_V_ERR_SE

OpenSSL: Error "Self-signed certificate in certificate chain"

Lunar Mushrooms: When I use the openssl API to verify the server certificate (self-signed), I get the following error: Error 1 Deep Look 19: Self-signed certificate in certificate chain According to the openssl documentation , this error (19) is "X509_V_ERR_SE

Invalid CA certificate with self-signed certificate chain

Tejas I have a self signed certificate chain with these commands and configured it on the Apache server but when i tryopenssl s_client -showcerts -servername server -connect my-host.local:443 -CAfile all.crt I am getting error from opensslVerify return code: 2

OpenSSL: Error "Self-signed certificate in certificate chain"

Lunar Mushrooms: When I use the openssl API to verify the server certificate (self-signed), I get the following error: Error 1 Deep Look 19: Self-signed certificate in certificate chain According to the openssl documentation , this error (19) is "X509_V_ERR_SE

Invalid CA certificate with self-signed certificate chain

Tejas I have a self signed certificate chain with these commands and configured it on the Apache server but when i tryopenssl s_client -showcerts -servername server -connect my-host.local:443 -CAfile all.crt I am getting error from opensslVerify return code: 2