jasonsims/aws-cloudfront-sign

PEM routines:PEM_read_bio:bad end line:pem_lib.c:802:

Closed this issue · 4 comments

Hey,

Thanks for this lib man, its pretty great.
One thing tho, i followed every guide and you npm readme, etc, but i get this error when attempting to create the signedUrl.

Im using mi RSA PRIVATE KEY as a String in my code:

( $ more pk-..pem file from terminal and copied the output to my .js file)

var privateKeyString =
'-----BEGIN RSA PRIVATE KEY-----\n'
'sdkfklfhksdfhskljfhsalkj( checked 64 character length) \n'
......
'u....................................................................................=\n'
'-----END RSA PRIVATE KEY-----';

var keypairId = 'some_random_rumber';

var cfsign = require('aws-cloudfront-sign');
var cloudfrontSignOptions = {
keypairId: keypairId,
privateKeyString:privateKeyString
};

...
//Actual invocation
function getUrl(){
var signedUrl = cfsign.getSignedUrl(path,cloudfrontSignOptions);
context.succeed(signedUrl);
}

I've tried every possible formatting of the RSA string, such as end of line to the last line, and many other things like that but with no success.

Is it related to this lib? I've searched everywhere, but i cant seem to fix it.

Thanks

Hitting the same issue.

I just saw your email.
No man, i've made the videos public so i can continue with my dev process, but i haven't been able to stream private videos this way. Please let me know if you find a way to do so.

Not sure if you're still wrangling with this, but I solved the issue. I created a folder called key and dropped my .pem file in there then referenced as follows:

var options = {keypairId: 'XXXXXXXXX', privateKeyPath: './key/yourkeyfile.pem', expireTime: (new Date().getTime() + 300000)}

Hey sorry it's been some time w/o a response! Were you able to resolve this? It sounds like something went wrong during the copy paste into the code. If anyone is still hitting this issue, checkout the example private key I've added in examples/signedURL.js and re-open this if you're unable to get it going.