Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL Error in nodejs

I'm trying to get a webpage via node https.request(). Doing so results in an error getting logged by my code. Using the node request module has the same result:

problem with request: 140398870042432:error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message:s23_clnt.c:658:

The following indicates the wrong SSL version is being used, but I cannot find a way to change the version: curl error: "sslv3 alert unexpected message". Using curl from my terminal returns a response as does hitting the URL in my browser (it is a login page). My code is below.

var request = require('request')
request.get("https://icmserver.wit.ie/balance", function(err, res, body) {
    if (err) {
        return console.log(err)
    }
    return body;
});

Does anyone have any idea what might be happening here?

like image 568
Evan Shortiss Avatar asked Jun 18 '12 22:06

Evan Shortiss


2 Answers

Try to use options = { secureProtocol: 'SSLv3_method' } in the request you are making.

like image 78
SuperShalabi Avatar answered Oct 20 '22 17:10

SuperShalabi


We hit the same problem. By default, request uses the https.globalAgent. So we added the code near the top of our script.

var https = require('https');
https.globalAgent.options.secureProtocol = 'SSLv3_method';

All of a sudden everything worked.

like image 33
Will Glass Avatar answered Oct 20 '22 17:10

Will Glass