remove deprecated functions
This commit is contained in:
parent
d4d57b96f7
commit
21bf389c73
|
@ -16,7 +16,7 @@ function b64ToBinstr(b64) {
|
||||||
return new Buffer(b64, 'base64').toString('binary');
|
return new Buffer(b64, 'base64').toString('binary');
|
||||||
}
|
}
|
||||||
|
|
||||||
function toAcmePrivateKey(forgePrivkey) {
|
function privatePemToJwk(forgePrivkey) {
|
||||||
//var forgePrivkey = forge.pki.privateKeyFromPem(privkeyPem);
|
//var forgePrivkey = forge.pki.privateKeyFromPem(privkeyPem);
|
||||||
|
|
||||||
// required in node.js 4.2.2 (but not io.js 1.6.3)
|
// required in node.js 4.2.2 (but not io.js 1.6.3)
|
||||||
|
@ -68,7 +68,7 @@ function generateRsaKeypair(bitlen, exp, cb) {
|
||||||
// for compat with python client account id
|
// for compat with python client account id
|
||||||
pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex');
|
pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex');
|
||||||
// json { n: ..., e: ..., iq: ..., etc }
|
// json { n: ..., e: ..., iq: ..., etc }
|
||||||
pems.privateKeyJwk = toAcmePrivateKey(keypair.privateKey);
|
pems.privateKeyJwk = privatePemToJwk(keypair.privateKey);
|
||||||
// deprecate
|
// deprecate
|
||||||
pems.privateKeyJson = pems.privateKeyJwk;
|
pems.privateKeyJson = pems.privateKeyJwk;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ function generateRsaKeypair(bitlen, exp, cb) {
|
||||||
cb(null, pems);
|
cb(null, pems);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseAccountPrivateKey(pkj, cb) {
|
function privateJwkToPems(pkj, cb) {
|
||||||
var pki = forge.pki;
|
var pki = forge.pki;
|
||||||
|
|
||||||
Object.keys(pkj).forEach(function (key) {
|
Object.keys(pkj).forEach(function (key) {
|
||||||
|
@ -113,13 +113,10 @@ function parseAccountPrivateKey(pkj, cb) {
|
||||||
, privateKeyJson: pkj
|
, privateKeyJson: pkj
|
||||||
// I would have chosen sha1 or sha2... but whatever
|
// I would have chosen sha1 or sha2... but whatever
|
||||||
, publicKeyMd5: crypto.createHash('md5').update(pubPem).digest('hex')
|
, publicKeyMd5: crypto.createHash('md5').update(pubPem).digest('hex')
|
||||||
|
, publicKeySha256: crypto.createHash('sha256').update(pubPem).digest('hex')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.generateRsaKeypair = generateRsaKeypair;
|
module.exports.generateRsaKeypair = generateRsaKeypair;
|
||||||
module.exports.privateJwkToPems = parseAccountPrivateKey;
|
module.exports.privateJwkToPems = privateJwkToPems;
|
||||||
module.exports.privatePemToJwk = toAcmePrivateKey;
|
module.exports.privatePemToJwk = privatePemToJwk;
|
||||||
|
|
||||||
// TODO deprecate
|
|
||||||
module.exports.toAcmePrivateKey = toAcmePrivateKey;
|
|
||||||
module.exports.parseAccountPrivateKey = parseAccountPrivateKey;
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ function b64ToBinstr(b64) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function toAcmePrivateKey(privkeyPem) {
|
function privatePemToJwk(privkeyPem) {
|
||||||
var forgePrivkey = forge.pki.privateKeyFromPem(privkeyPem);
|
var forgePrivkey = forge.pki.privateKeyFromPem(privkeyPem);
|
||||||
|
|
||||||
// required in node.js 4.2.2 (but not io.js 1.6.3)
|
// required in node.js 4.2.2 (but not io.js 1.6.3)
|
||||||
|
@ -55,7 +55,7 @@ function generateRsaKeypair(bitlen, exp, cb) {
|
||||||
// for compat with python client account id
|
// for compat with python client account id
|
||||||
pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex');
|
pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex');
|
||||||
// json { n: ..., e: ..., iq: ..., etc }
|
// json { n: ..., e: ..., iq: ..., etc }
|
||||||
pems.privateKeyJwk = toAcmePrivateKey(pems.privateKeyPem);
|
pems.privateKeyJwk = privatePemToJwk(pems.privateKeyPem);
|
||||||
pems.privateKeyJson = pems.privateKeyJwk;
|
pems.privateKeyJson = pems.privateKeyJwk;
|
||||||
|
|
||||||
// TODO thumbprint
|
// TODO thumbprint
|
||||||
|
@ -63,12 +63,13 @@ function generateRsaKeypair(bitlen, exp, cb) {
|
||||||
cb(null, pems);
|
cb(null, pems);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseAccountPrivateKey(pkj, cb) {
|
function privateJwkToPems(pkj, cb) {
|
||||||
Object.keys(pkj).forEach(function (key) {
|
Object.keys(pkj).forEach(function (key) {
|
||||||
pkj[key] = new Buffer(pkj[key], 'base64');
|
pkj[key] = new Buffer(pkj[key], 'base64');
|
||||||
});
|
});
|
||||||
|
|
||||||
var priv;
|
var priv;
|
||||||
|
var pems;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
priv = ursa.createPrivateKeyFromComponents(
|
priv = ursa.createPrivateKeyFromComponents(
|
||||||
|
@ -86,16 +87,22 @@ function parseAccountPrivateKey(pkj, cb) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb(null, {
|
pems = {
|
||||||
privateKeyPem: priv.toPrivatePem.toString('ascii')
|
privateKeyPem: priv.toPrivatePem().toString('ascii')
|
||||||
, publicKeyPem: priv.toPublicPem.toString('ascii')
|
, publicKeyPem: priv.toPublicPem().toString('ascii')
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// for account id
|
||||||
|
pems.publicKeySha256 = crypto.createHash('sha256').update(pems.publicKeyPem).digest('hex');
|
||||||
|
// for compat with python client account id
|
||||||
|
pems.publicKeyMd5 = crypto.createHash('md5').update(pems.publicKeyPem).digest('hex');
|
||||||
|
// json { n: ..., e: ..., iq: ..., etc }
|
||||||
|
pems.privateKeyJwk = privatePemToJwk(pems.privateKeyPem);
|
||||||
|
pems.privateKeyJson = pems.privateKeyJwk;
|
||||||
|
|
||||||
|
cb(null, pems);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.generateRsaKeypair = generateRsaKeypair;
|
module.exports.generateRsaKeypair = generateRsaKeypair;
|
||||||
module.exports.privateJwkToPems = parseAccountPrivateKey;
|
module.exports.privateJwkToPems = privateJwkToPems;
|
||||||
module.exports.privatePemToJwk = toAcmePrivateKey;
|
module.exports.privatePemToJwk = privatePemToJwk;
|
||||||
|
|
||||||
// TODO deprecate
|
|
||||||
module.exports.toAcmePrivateKey = toAcmePrivateKey;
|
|
||||||
module.exports.parseAccountPrivateKey = parseAccountPrivateKey;
|
|
||||||
|
|
Loading…
Reference in New Issue