Skip to content

.getPeerCertificate() on https.request() #7672

@mykiimike

Description

@mykiimike

Hi

.getPeerCertificate() does not returned fingerprint after first https.request(). It seems to be a problem with https.agent. If i set agent to false during https.request(opts) then i got correctly the fingerprint at each time.

Here is an example:

const https = require("https");

function request() {
    var options = {
        hostname: 'www.google.com',
        port: 443,
        path: "/",
        method: 'GET',
        // turning this to True makes fingerprint works again (agent's connections are closed);
        //agent: false, 
        rejectUnauthorized: false
    };

    var req = https.request(options, (res) => {
        res.fingerprint = res.connection.getPeerCertificate().fingerprint;
        var data = '';
        res.on('data', (d) => {
            data += d;
        });
        res.on('end', () => {
            console.log("got data", res.fingerprint);
            setTimeout(request, 1000);
        });

    }).on('error', (e) => {
        console.error(e);
    });
    req.end();
}

request();

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.httpsIssues or PRs related to the https subsystem.tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions