Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't capture exceptions, passphrase/pfx #2217

Closed
jmmgr opened this issue May 19, 2016 · 1 comment
Closed

Can't capture exceptions, passphrase/pfx #2217

jmmgr opened this issue May 19, 2016 · 1 comment

Comments

@jmmgr
Copy link

jmmgr commented May 19, 2016

Hello,
I'm using request 2.55.0 and I'm having problems capturing one exception.
This is my code using https:

var https = require('https');
var options_https = {
    hostname: 'one_url',
    port: 443,
    path: '/',
    method: 'POST',
    headers: {
        'Content-Type': 'text/plain'
    },
    maxattempts: 1,
    body: 'one body',
    pfx: {
        type: 'Buffer',
        data: [0, 130, 17, 128, 2, 1, 3]
    },
    passphrase: 'one_passphrase'
};

options_https.agent = new https.Agent(options_https);

var req;
try {
    req = https.request(options_https, function (res) {
        console.log('this is the response:', res);
    });
    req.end();
} catch (e) {
    console.log('THIS IS WERE I CAPTURE THE EXCEPTION', e);
}

This is my code using request:

var request = require('request');
var options = {
    url: 'https://www.one_url.com',
    method: 'POST',
    body: 'one body',
    headers: {
        'Content-Type': 'text/plain'
    },
    agentOptions: {
        pfx: {
            type: 'Buffer',
            data: [0, 130, 17, 128, 2, 1, 3]
        },
        passphrase: 'one_passphrase'
    }
};

console.log(options);

request(options, function (err, result, body) {
    console.log('this is the err ', err);
    console.log('this is the result ', result);
    console.log('this is the body ', body);
}).on('error', function (exception) {
    console.log('this is he exception, plese dont bury ', exception);
});

Am I doing something wrong? in the request example I don't capture the exception created:

_tls_common.js:130
      c.context.loadPKCS12(pfx, passphrase);
                ^

Error: Unable to load BIO
    at Error (native)
    at Object.createSecureContext (_tls_common.js:130:17)
    at Object.exports.connect (_tls_wrap.js:958:21)
    at Agent.createConnection (https.js:73:22)
    at Agent.createSocket (_http_agent.js:174:16)
    at Agent.addRequest (_http_agent.js:143:23)
    at new ClientRequest (_http_client.js:133:16)
    at Object.exports.request (http.js:31:10)
    at Object.exports.request (https.js:163:15)
    at Request.start (/Users/jesus/git/postmen.worker/node_modules/request/request.js:963:30)

Jesus

@jmmgr
Copy link
Author

jmmgr commented May 19, 2016

Seems already published in: #2164
so need 2.7.1

@jmmgr jmmgr closed this as completed May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant