Skip to content

Error: connect EPERM when connecting to https server with self signed certificate #20019

@bamanuel

Description

@bamanuel
  • Version: v8.10.0
  • Platform: Windows 10 x64 (behind proxy)
  • Subsystem:

When connecting to https url with self signed certificate, the following error is thrown:

Error: connect EPERM /
at Object._errnoException (util.js:1019:11)
at _exceptionWithHostPort (util.js:1041:20)
at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1175:14)

The issue isn't system independent and happens starting with nodev8.6.0. The code below works fine on nodev8.5.0 or lower on same machine

const https = require("https");
const fs = require("fs");
var globalAgent = https.globalAgent;
globalAgent.options = {ca: [fs.readFileSync('./caTrust.cer')]};// caTrust.cer contains self signed certificate for target url

const url = 'https://target.localhost'
https.get(url, response => {
    console.log(response);
});

When using request library to make the https call, it throws a slightly different error: Error: connect ENOENT

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpsIssues or PRs related to the https subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions