Node.js - Using https.request () with an internal CA

To whom do I get https.request () to trust my internally signed server certificate. Here is a short example of the code that I run in v0.10.25:

var options = {
     hostname: 'encrypted.mydomain.local',
     port: 443,
     path: '/',
     method: 'GET'
};

var https = require('https')
https.request(options)

I run this on a Windows system where my internal root CA trusts the system level, but whenever I make such a request, I get an exception

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: CERT_UNTRUSTED
    at SecurePair.<anonymous> (tls.js:1370:32)
    at SecurePair.EventEmitter.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:982:10)
    at CleartextStream.read [as _read] (tls.js:469:13)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)
    at EncryptedStream.write [as _write] (tls.js:366:25)
    at doWrite (_stream_writable.js:223:10)
    at writeOrBuffer (_stream_writable.js:213:5)
    at EncryptedStream.Writable.write (_stream_writable.js:180:11)
    at write (_stream_readable.js:583:24)

For more details, all this happens inside the node-atlassian-crowd module that I am trying to use for authentication

+4
source share
2 answers

ca: cafile.pem . . http://nodejs.org/api/https.html#https_https_request_options_callback.

:

tls.connect(). , globalAgent .

pfx: , CA SSL. null.

: SSL. null.

passphrase: pfx. null.

cert: x509 . null.

ca: .

CA - var casigningcert = fs.readFileSync('keys/ca-certsigning-cert.pem'), , :

var options = {
  hostname: 'encrypted.mydomain.local',
  port: 443,
  path: '/',
  method: 'GET',
  ca: casigningcert
  };
+7

, "ca: "?

0

Source: https://habr.com/ru/post/1530656/


All Articles