request: Error: DEPTH_ZERO_SELF_SIGNED_CERT
I’m using self-signed test certificates in my apache2 server and when I call request I get the following error:
Error: DEPTH_ZERO_SELF_SIGNED_CERT
I’m using the following code below to test it. Notice that I’m also using needle and it works with the rejectUnauthorized=true option. I could not find an equivalent on request (I’ve tried strictSSL=false but I guess that’s the default). I couldn’t find any other samples related do the problem either.
var request = require('request'),
needle = require('needle');
request('https://127.0.0.1', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log("REQUEST:"+body);
} else {
console.error("REQUEST: "+error)
}
});
needle.get('https://127.0.0.1',{rejectUnauthorized:false},function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log("NEEDLE:"+body);
}
});
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 51 (12 by maintainers)
Commits related to this issue
- set strictSSL false default to use couchdb self-signed cert, ref mikeal/request#418 — committed to cutting-room-floor/backbone-couch by mikemorris 10 years ago
- Hopefully fixing v0.8.26 on travis. see https://github.com/mikeal/request/issues/418 — committed to mqttjs/MQTT.js by mcollina 10 years ago
- Fix for 'DEPTH_ZERO_SELF_SIGNED_CERT' issue, see: https://github.com/mikeal/request/issues/418 — committed to Strongbow-review/fh-fhc by deleted user 11 years ago
- Ticket 4088 Upgrade fh-fhc to node 0.10x: Fix for 'DEPTH_ZERO_SELF_SIGNED_CERT' issue, see: https://github.com/mikeal/request/issues/418 — committed to Strongbow-review/fh-fhc by deleted user 11 years ago
rejectUnauthorized: falsedid not work for me. Instead, adding the following removed the error:rejectUnauthorized: falseThe code you need is:
Edit: I removed the lame comment that I made, cause, that’s just lame of me…
add this and it should solve it:
https.globalAgent.options.rejectUnauthorized = false;
Hey guys,
Thanks to everyone who works on the library. I was trying to use self-signed cert for some testing and get the same error. I’ve included details below. Let me know if you need anything else. I’ve tried all combinations of using strictSSL and rejectUnauthorized but it doesn’t seem to work.
Node version: 0.10.10 OS: Windows 7 x64 OpenSSL: Win32 1.0.1e Cert generated using:
openssl genrsa –out priv.pem 1024openssl req -x509 -new -key priv.pem -days 3650 -out cert.crtCode for creating server
Using request like so:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = “0”;
Works for restler as well.
Same problem here. Using node v0.10.1 and latest request version.
For those who wish to understand a principle.
https://nodejs.org/dist/v0.12.9/docs/api/tls.html#tls_tls_connect_options_callback