WIP Building out all features necessary for Let's Encrypt #6
10
lib/acme.js
10
lib/acme.js
|
@ -827,6 +827,16 @@ ACME._getCertificate = function (me, options) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ACME._generateCsrWeb64 = function (me, options, validatedDomains) {
|
ACME._generateCsrWeb64 = function (me, options, validatedDomains) {
|
||||||
|
var csr;
|
||||||
|
if (options.csr) {
|
||||||
|
csr = options.csr;
|
||||||
|
// if der, convert to base64
|
||||||
|
if ('string' !== typeof csr) { csr = Enc.bufToUrlBase64(csr); }
|
||||||
|
// nix PEM headers, if any
|
||||||
|
if ('-' === csr[0]) { csr = csr.split(/\n+/).slice(1, -1).join(''); }
|
||||||
|
csr = Enc.base64ToUrlBase64(csr.trim().replace(/\s+/g, ''));
|
||||||
|
return Promise.resolve(csr);
|
||||||
|
}
|
||||||
return ACME._importKeypair(me, options.domainKeypair).then(function (pair) {
|
return ACME._importKeypair(me, options.domainKeypair).then(function (pair) {
|
||||||
return me.CSR({ jwk: pair.private, domains: validatedDomains, encoding: 'der' }).then(function (der) {
|
return me.CSR({ jwk: pair.private, domains: validatedDomains, encoding: 'der' }).then(function (der) {
|
||||||
return Enc.bufToUrlBase64(der);
|
return Enc.bufToUrlBase64(der);
|
||||||
|
|
|
@ -66,8 +66,11 @@ Enc.numToHex = function (d) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Enc.bufToUrlBase64 = function (u8) {
|
Enc.bufToUrlBase64 = function (u8) {
|
||||||
return Enc.bufToBase64(u8)
|
return Enc.base64ToUrlBase64(Enc.bufToBase64(u8));
|
||||||
.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
};
|
||||||
|
|
||||||
|
Enc.base64ToUrlBase64 = function (str) {
|
||||||
|
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
Enc.bufToBase64 = function (u8) {
|
Enc.bufToBase64 = function (u8) {
|
||||||
|
|
Loading…
Reference in New Issue