|
|
@ -8,7 +8,6 @@ var fs = PromiseA.promisifyAll(require('fs')); |
|
|
|
var sfs = require('safe-replace'); |
|
|
|
var LE = require('../'); |
|
|
|
var LeCore = PromiseA.promisifyAll(require('letiny-core')); |
|
|
|
var leCrypto = PromiseA.promisifyAll(LeCore.leCrypto); |
|
|
|
var Accounts = require('./accounts'); |
|
|
|
|
|
|
|
var merge = require('./common').merge; |
|
|
@ -199,7 +198,7 @@ function writeCertificateAsync(args, defaults, handlers) { |
|
|
|
, sfs.writeFileAsync( |
|
|
|
privkeyArchive |
|
|
|
// TODO nix args.key, args.domainPrivateKeyPem ??
|
|
|
|
, (result.privkey || result.key) || RSA.exportPrivateKey(args.domainKeypair) |
|
|
|
, (result.privkey || result.key) || RSA.exportPrivatePem(args.domainKeypair) |
|
|
|
, 'ascii' |
|
|
|
) |
|
|
|
]); |
|
|
@ -213,7 +212,7 @@ function writeCertificateAsync(args, defaults, handlers) { |
|
|
|
, sfs.writeFileAsync( |
|
|
|
privkeyPath |
|
|
|
// TODO nix args.key, args.domainPrivateKeyPem ??
|
|
|
|
, (result.privkey || result.key) || RSA.exportPrivateKey(args.domainKeypair) |
|
|
|
, (result.privkey || result.key) || RSA.exportPrivatePem(args.domainKeypair) |
|
|
|
, 'ascii' |
|
|
|
) |
|
|
|
]); |
|
|
@ -235,7 +234,7 @@ function writeCertificateAsync(args, defaults, handlers) { |
|
|
|
|
|
|
|
// TODO nix args.key, args.domainPrivateKeyPem ??
|
|
|
|
// some ambiguity here...
|
|
|
|
, privkey: (result.privkey || result.key) || RSA.exportPrivateKey(args.domainKeypair) |
|
|
|
, privkey: (result.privkey || result.key) || RSA.exportPrivatePem(args.domainKeypair) |
|
|
|
, fullchain: result.fullchain || (result.cert + '\n' + result.chain) |
|
|
|
, chain: (result.chain || result.ca) |
|
|
|
// especially this one... might be cert only, might be fullchain
|
|
|
@ -254,15 +253,25 @@ function getCertificateAsync(args, defaults, handlers) { |
|
|
|
|
|
|
|
if (!args.domainKeyPath) { |
|
|
|
// TODO use default path ???
|
|
|
|
if (args.debug) { |
|
|
|
console.log('[domainKeyPath]: none'); |
|
|
|
} |
|
|
|
promise = RSA.generateKeypairAsync(args.rsaKeySize, 65537, keypairOpts); |
|
|
|
} |
|
|
|
|
|
|
|
if (args.domainKeyPath) { |
|
|
|
if (args.debug) { |
|
|
|
console.log('[domainKeyPath]:', args.domainKeyPath); |
|
|
|
} |
|
|
|
promise = fs.readFileAsync(args.domainKeyPath, 'ascii').then(function (pem) { |
|
|
|
return RSA.import({ privateKeyPem: pem }); |
|
|
|
}, function (err) { |
|
|
|
}, function (/*err*/) { |
|
|
|
return RSA.generateKeypairAsync(args.rsaKeySize, 65537, keypairOpts).then(function (keypair) { |
|
|
|
return fs.writeFileAsync(args.domainKeyPath, keypair.privateKeyPem, 'ascii'); |
|
|
|
return mkdirpAsync(path.dirname(args.domainKeyPath)).then(function () { |
|
|
|
return fs.writeFileAsync(args.domainKeyPath, keypair.privateKeyPem, 'ascii').then(function () { |
|
|
|
return keypair; |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|