'request' : Error: { Error: self signed certificate in certificate chain
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to fetch some information from below mentioned API and I'm getting below error
const request = require('request');
var options = {
url : 'https://example.com',
}
OR
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
console.log(options)
request(options, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body );
});
error: { Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
sample pem file
-----BEGIN CERTIFICATE-----
Key
-----END CERTIFICATE-----
I don't want to use either NODE_TLS_REJECT_UNAUTHORIZED='0' or rejectUnauthorized: false
node.js request
add a comment |
I'm trying to fetch some information from below mentioned API and I'm getting below error
const request = require('request');
var options = {
url : 'https://example.com',
}
OR
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
console.log(options)
request(options, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body );
});
error: { Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
sample pem file
-----BEGIN CERTIFICATE-----
Key
-----END CERTIFICATE-----
I don't want to use either NODE_TLS_REJECT_UNAUTHORIZED='0' or rejectUnauthorized: false
node.js request
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32
add a comment |
I'm trying to fetch some information from below mentioned API and I'm getting below error
const request = require('request');
var options = {
url : 'https://example.com',
}
OR
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
console.log(options)
request(options, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body );
});
error: { Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
sample pem file
-----BEGIN CERTIFICATE-----
Key
-----END CERTIFICATE-----
I don't want to use either NODE_TLS_REJECT_UNAUTHORIZED='0' or rejectUnauthorized: false
node.js request
I'm trying to fetch some information from below mentioned API and I'm getting below error
const request = require('request');
var options = {
url : 'https://example.com',
}
OR
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
console.log(options)
request(options, function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body );
});
error: { Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'SELF_SIGNED_CERT_IN_CHAIN' }
sample pem file
-----BEGIN CERTIFICATE-----
Key
-----END CERTIFICATE-----
I don't want to use either NODE_TLS_REJECT_UNAUTHORIZED='0' or rejectUnauthorized: false
node.js request
node.js request
edited Nov 26 '18 at 17:35
Ganesh Karamala
asked Nov 26 '18 at 10:18
Ganesh KaramalaGanesh Karamala
443612
443612
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32
add a comment |
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32
add a comment |
1 Answer
1
active
oldest
votes
As per the fine manual:
It is possible to accept other certificates than those signed by
generally allowed Certificate Authorities (CAs). This can be useful,
for example, when using self-signed certificates. To require a
different root certificate, you can specify the signing CA by adding
the contents of the CA's certificate file to the agentOptions. The certificate
the domain presents must be signed by the root certificate specified:
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53478981%2frequest-error-error-self-signed-certificate-in-certificate-chain%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As per the fine manual:
It is possible to accept other certificates than those signed by
generally allowed Certificate Authorities (CAs). This can be useful,
for example, when using self-signed certificates. To require a
different root certificate, you can specify the signing CA by adding
the contents of the CA's certificate file to the agentOptions. The certificate
the domain presents must be signed by the root certificate specified:
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
add a comment |
As per the fine manual:
It is possible to accept other certificates than those signed by
generally allowed Certificate Authorities (CAs). This can be useful,
for example, when using self-signed certificates. To require a
different root certificate, you can specify the signing CA by adding
the contents of the CA's certificate file to the agentOptions. The certificate
the domain presents must be signed by the root certificate specified:
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
add a comment |
As per the fine manual:
It is possible to accept other certificates than those signed by
generally allowed Certificate Authorities (CAs). This can be useful,
for example, when using self-signed certificates. To require a
different root certificate, you can specify the signing CA by adding
the contents of the CA's certificate file to the agentOptions. The certificate
the domain presents must be signed by the root certificate specified:
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
As per the fine manual:
It is possible to accept other certificates than those signed by
generally allowed Certificate Authorities (CAs). This can be useful,
for example, when using self-signed certificates. To require a
different root certificate, you can specify the signing CA by adding
the contents of the CA's certificate file to the agentOptions. The certificate
the domain presents must be signed by the root certificate specified:
var options = {
url : 'https://example.com',
agentOptions: {
ca: fs.readFileSync('ca.pem')
}
}
answered Nov 26 '18 at 11:13
robertkleprobertklep
140k19238251
140k19238251
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
add a comment |
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
This also seems doesn't work for me... My pem file contains begin followed by a key and then end.
– Ganesh Karamala
Nov 26 '18 at 15:33
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
Are you sure it's the correct certificate? Because a quick PoC works just fine for me: gist.github.com/527cfb3d9d731d48733194dc35c205dd
– robertklep
Nov 26 '18 at 17:45
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
I'm not sure whether server has same certificate or not like you created in poc. I exported .cer file from chrome browser.
– Ganesh Karamala
Nov 27 '18 at 1:36
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
.cer looks like. -----BEGIN CERTIFICATE----- Key -----END CERTIFICATE-----
– Ganesh Karamala
Nov 27 '18 at 1:40
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
If I do the same (save the self-signed certificate from Chrome), it still works for me, so not sure why it doesn't work for you.
– robertklep
Nov 27 '18 at 8:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53478981%2frequest-error-error-self-signed-certificate-in-certificate-chain%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
then you have to use a trusted certificate...
– RidgeA
Nov 26 '18 at 10:20
the options that you don't want to use, they are your solution or you have to use a trusted certificate as @RidgeA said
– Anouar Kacem
Nov 26 '18 at 10:27
how would I know whether certificate is trusted one or not
– Ganesh Karamala
Nov 26 '18 at 10:27
I want to use trusted certificate-> exported from crome export option and saved as .cer file
– Ganesh Karamala
Nov 26 '18 at 10:28
below option also doesn't work from me var options = { url : 'example.com', ca: [ fs.readFileSync('cp.pem','utf-8') ] }
– Ganesh Karamala
Nov 26 '18 at 10:32