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

error:0906D06C:PEM routines:PEM_read_bio:no start line #3

Closed
GlennGeenen opened this issue Mar 13, 2015 · 16 comments
Closed

error:0906D06C:PEM routines:PEM_read_bio:no start line #3

GlennGeenen opened this issue Mar 13, 2015 · 16 comments
Assignees

Comments

@GlennGeenen
Copy link

When I test locally the mollie payment is created just fine and I get redirected to mollie. Whenever I try the same on my test server (Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-43-generic x86_64)) I get the following error when I try to create a payment.

The only difference is that my test server runs node v0.12.0 while I run v0.10.33.

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line at Error (native) at Object.createSecureContext (_tls_common.js:130:19) at Object.exports.connect (_tls_wrap.js:850:21) at Agent.createConnection (https.js:82:14) at Agent.createSocket (_http_agent.js:194:16) at Agent.addRequest (_http_agent.js:166:23) at new ClientRequest (_http_client.js:154:16) at Object.exports.request (http.js:49:10) at Object.exports.request (https.js:136:15) at Client.module.exports.Mollie.API.Client.Client.callRest (/var/www/test/node_modules/mollie-api-node/lib/mollie/api/client.js:91:23) at Payments.module.exports.Mollie.API.Resource.Base.Base.create (/var/www/test/node_modules/mollie-api-node/lib/mollie/api/resource/base.js:66:23)

Edit: I installed v0.10.37 on the server, module works for node v0.10 not for v0.12.

@willemstuursma
Copy link
Contributor

Hi @GlennGeenen. This is most likely a problem with the underlaying transport layer. We use SNI to attach multiple certificates to the same IP-address. I fear that you will need to upgrade your server's node version.

@GlennGeenen
Copy link
Author

@willemstuursma The module is not compatible with node v0.12.0. I added sample code. This works in node v0.10.37 and not in v0.12.0.

var Mollie = require('mollie-api-node');
var http = require('http');

var mollie = new Mollie.API.Client();
mollie.setApiKey('molliekey');

var pay = {
    amount: 10,
    description: 'Payment Test',
    redirectUrl: 'http://localhost:1337/back'
};

http.createServer(function (req, res) {

    if (req.url === '/back') {

        res.end('Welcome Back\n');

    } else {

        mollie.payments.create(pay, function (payment) {
            if (payment.error) {
                console.error('Payment Error: ' + payment.error);
            }
            res.writeHead(302, {
                Location: payment.getPaymentUrl()
            });
            return res.end();
        });

    }
}).listen(1337, '127.0.0.1');

@amirshakya2010
Copy link

We have the same issue when i upgraded my node version from the 0.10.21 to 0.12.4.

Module is not compatible with new version of node 0.12.4.

@GlennGeenen
Copy link
Author

I'm still running on v0.10.38 because of this. I'll look into the problem when I have some time since I want to upgrade node.

@willemstuursma
Copy link
Contributor

Thanks, we are going to look into this. If you could provide a PR, that would help immensely.

@GlennGeenen
Copy link
Author

It seems to crash on reading/loading the certificate. Node v0.12 has SSLv2 and SSLv3 disabled, could that be the problem?

Edit: Not the problem, SSLv2 and SSLv3 are disabled since v0.10.33 and it works on v0.10.38. It all look like something is wrong with the certificate (that's what the errors say). Maybe some of the v0.12 changes to buffer created this problem? How is the certificate created?

@jasminjane
Copy link

Hi, we are also experiencing this. Has this issue been resolved? Is there a work-around?

@daanbrandt
Copy link

Hey there.
Ive been working on this all day and can't make it work :(
If anyone has a work-arund please post
greetz,

Voidkn1ghtz

@GlennGeenen
Copy link
Author

I've also spent some time on it, as far as I understand reading certdata.txt fails in node v0.12 while it works in v0.10. I guess it's a matter of recreating certdata.txt?

@jasminjane
Copy link

certdata.txt? Where can I find this?

@GlennGeenen
Copy link
Author

@jasminjane
Copy link

Thanks for your quick response, Glenn. But what I don't quite get yet is how I can recreate this file?

@lvgunst
Copy link
Contributor

lvgunst commented Jul 21, 2015

Have you tried using the .pem file from our PHP client (https://raw.githubusercontent.com/mollie/mollie-api-php/master/src/Mollie/API/cacert.pem) on Node v0.12?

Place it next to certdata.txt and change https://github.com/mollie/mollie-api-node/blob/master/lib/mollie/api/client.js#L84

@GlennGeenen
Copy link
Author

@lvgunst When I use the cacert.pem I can read the certificate and send a create payment request that provides following error:

Payment Error: {"type":"request","message":"Unauthorized request","links":{"documentation":"https://www.mollie.com/en/docs"}

@paetor paetor assigned paetor and unassigned mollierobbert Jul 24, 2015
@paetor
Copy link

paetor commented Jul 24, 2015

@amirshakya2010, @GlennGeenen, @jasminjane, @daanbrandt: Release 1.0.4 should fix this issue.

The format of the cacert was incorrect but due to the fact that it was also incorrectly the single element of an array this error didn't surface in older versions of node. Older versions would then use the system-installed CA instead which works fine for most of us with a soundly setup system.
With node v0.12 the error was no longer silently ignored and so caused the problem. I've corrected the format of the cacert fixed the buggy array use. Now this file is actually used on all versions of node and also prevents the error from happening in node v0.12.

@paetor
Copy link

paetor commented Jul 24, 2015

@GlennGeenen "The Unauthorized request" error usually means you're not using valid credentials (api-key).

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

8 participants