From 09cdf6c77df39655c2dd2e0f7b6dba8d2bfe51f2 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 9 Nov 2014 20:14:25 +0000 Subject: [PATCH] Add missing \n at the end of Public Pem causing errors. --- rsa-wrap.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rsa-wrap.js b/rsa-wrap.js index 3bf1d06..cc57e4e 100644 --- a/rsa-wrap.js +++ b/rsa-wrap.js @@ -224,7 +224,7 @@ function PublicKey(rsa) { } function toPublicPem(encoding) { - return encodeBuffer(rsa.getPublicPEM(), encoding); + return encodeBuffer(rsa.getPublicPEM() + "\n", encoding); } function toPublicSsh(encoding) { @@ -339,10 +339,10 @@ function PrivateKey(rsa) { */ function createPublicKey(pem, encoding) { var rsa = new RsaWrap(); - //pem = decodeString(pem, encoding); + pem = decodeString(pem, encoding); try { - rsa.loadFromPEM(pem); + rsa.loadFromPEM(pem.toString('utf8')); } catch (ex) { if (!isPublicKeyPem(pem)) { throw new Error("Not a public key."); @@ -548,7 +548,7 @@ function matchingPublicKeys(key1, key2) { // This isn't the most efficient implementation, but it will suffice: // We convert both to ssh form, which has very little leeway for // variation, and compare bytes. - + var ssh1 = key1.toPublicSsh(UTF8); var ssh2 = key2.toPublicSsh(UTF8);