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

SSL error on secure connection #151

Open
jlporter opened this issue Feb 26, 2012 · 8 comments · May be fixed by #222
Open

SSL error on secure connection #151

jlporter opened this issue Feb 26, 2012 · 8 comments · May be fixed by #222

Comments

@jlporter
Copy link

I recently tried to update to cradle 0.6.1 from 0.5.8 and am getting SSL errors when attempting to connect to my Cloudant hosted DB. Here is the test program I am using.

var http = require('http');
var cradle = require('cradle');

var cradleService = new(cradle.Connection)('app1234567.heroku.cloudant.com', 443, {
    secure: true,
    auth: {username: 'app1234567.heroku', password: 'notreallymypassword'} 
});

cradleService.info(function (info) {
    console.log('callback');
    console.log(info);
});

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World');
}).listen(5000, '127.0.0.1');

When I run this, the callback from info (or any of the other cradle API function) has the following error message
[Error: 140735330154848:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:683: ]

I am testing with node v0.6.10.

@mrmarbles
Copy link

I just got this same error. +1

@deitch
Copy link

deitch commented Mar 26, 2012

+1 just got the same thing.

@deitch
Copy link

deitch commented Mar 26, 2012

I found the problem. It ignores {secure:true}. In this._url (cradle.js L254), it sets the uri to https if the protocol was set, and it sets options.secure based on protocol in the initialization, but never the other way around.

If you explicitly set "https://" it should work.

@deitch
Copy link

deitch commented Mar 26, 2012

CONFIRMED.

@cedricmay
Copy link

Same here.

@adambreen
Copy link

I was having this issue, until I realised that I wasn't working with the 0.6.x versions of Cradle.

If you're following the tutorial here: http://blog.nodejitsu.com/a-simple-webservice-in-nodejs
(or http://ddewaele.blogspot.com.au/2012/04/nodejs-on-apple-os-x-lion.html)

... and you cloned the example code from https://github.com/indexzero/nodejs-intro.git

... then, using Cloudant, you'll get the above-reported issues.

The problem is that the example code's package.json sets Cradle to 0.5.x - obviously the Cloudant-friendly updates are contained somewhere in the 0.6.x stream.

How to test:

  1. npm install cradle # this will put the latest version of cradle in ./node_modules. Try it outside your example code folder.
  2. start node console

var cradle = require('cradle');
var conn = new (cradle.Connection)('appXXXXX.heroku.cloudant.com', 80, {auth:{username:"appXXXXXXX.heroku", password:"XXXXXXXXXXXX"}});
conn.databases(function(a,b){ console.log(a,b); });

output should be a list of the databases you have on your Cloudant host
eg. for me it was:
null [ 'basic', 'test' ]

@jedrichards
Copy link

Also having this error when attempting to connect to a Cloudant database over SSL from inside a Heroku app (Node 0.8.14, Cradle 0.6.4).

[Error: 139860364240672:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:683:]

As far as I can see @deitch is correct. Setting secure=true in your options isn't enough, you need to add https:// to the start of your hostname too.

@ghost
Copy link

ghost commented Apr 12, 2013

Another thing that can cause this is asking to use port 80 on the end of a hostname with the protocol https :)

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

Successfully merging a pull request may close this issue.

6 participants