|
|
@ -494,25 +494,22 @@ module.exports.create = function (gl) { |
|
|
|
|
|
|
|
// returns pems
|
|
|
|
return gl.store.certificates.checkAsync(args).then(function (cert) { |
|
|
|
if (cert) { |
|
|
|
cert = utils.attachCertInfo(cert); |
|
|
|
if (utils.certHasDomain(cert, args.domain)) { |
|
|
|
log(args.debug, 'checkAsync found existing certificates'); |
|
|
|
if (!cert) { log(args.debug, 'checkAsync failed to find certificates'); return null; } |
|
|
|
|
|
|
|
if (cert.privkey) { |
|
|
|
cert = utils.attachCertInfo(cert); |
|
|
|
if (utils.certHasDomain(cert, args.domain)) { |
|
|
|
log(args.debug, 'checkAsync found existing certificates'); |
|
|
|
|
|
|
|
if (cert.privkey) { |
|
|
|
return cert; |
|
|
|
} else { |
|
|
|
return gl.store.certificates.checkKeypairAsync(args).then(function (keypair) { |
|
|
|
cert.privkey = RSA.exportPrivatePem(keypair).privateKeyPem; |
|
|
|
return cert; |
|
|
|
} else { |
|
|
|
return gl.store.certificates.checkKeypairAsync(args).then(function (keypair) { |
|
|
|
cert.privkey = RSA.exportPrivatePem(keypair).privateKeyPem; |
|
|
|
return cert; |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
log(args.debug, 'checkAsync found mismatched / incomplete certificates'); |
|
|
|
} |
|
|
|
|
|
|
|
log(args.debug, 'checkAsync failed to find certificates'); |
|
|
|
return null; |
|
|
|
log(args.debug, 'checkAsync found mismatched / incomplete certificates'); |
|
|
|
}); |
|
|
|
} |
|
|
|
// Certificates
|
|
|
|