remove non-core stuff
This commit is contained in:
parent
65af1c5ddc
commit
367766b3c8
|
@ -1,77 +0,0 @@
|
|||
options.newReg=options.newReg || 'https://acme-v01.api.letsencrypt.org/acme/new-reg';
|
||||
|
||||
if (!options.email) {
|
||||
return cb(new Error('No "email" option specified!'));
|
||||
}
|
||||
if (typeof options.domains==='string') {
|
||||
state.domains=options.domains.split(/[, ]+/);
|
||||
} else if (options.domains && options.domains instanceof Array) {
|
||||
state.domains=options.domains.slice();
|
||||
} else {
|
||||
return cb(new Error('No valid "domains" option specified!'));
|
||||
}
|
||||
|
||||
if ((_DEBUG=options.debug)) {
|
||||
if (!''.green) {
|
||||
require('colors');
|
||||
}
|
||||
log=console.log.bind(console);
|
||||
} else {
|
||||
log=NOOP;
|
||||
}
|
||||
|
||||
if (options.fork && !~process.argv.indexOf('--letiny-fork')) {
|
||||
state.child=child.fork(__filename, ['--letiny-fork']);
|
||||
if (options.challenge) {
|
||||
return cb(new Error('fork+challenge not supported yet'));
|
||||
}
|
||||
state.child.send({request:options});
|
||||
state.child.on('message', function(msg) {
|
||||
var res;
|
||||
if (msg.result) {
|
||||
res=msg.result;
|
||||
cb(res.err ? new Error(res.err) : null, res.cert, res.key, res.ca);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.accountKey) {
|
||||
if (options.accountKey.length>255) {
|
||||
state.accountKeyPEM=options.accountKey;
|
||||
} else {
|
||||
try {
|
||||
state.accountKeyPEM=fs.readFileSync(options.accountKey);
|
||||
} catch(err) {
|
||||
if (err.code==='ENOENT') {
|
||||
makeAccountKeyPair(true);
|
||||
} else {
|
||||
return handleErr(err, 'Failed to load accountKey');
|
||||
}
|
||||
}
|
||||
try {
|
||||
state.accountKeyPair=cryptoUtil.importPemPrivateKey(state.accountKeyPEM);
|
||||
} catch(err) {
|
||||
return handleErr(err, 'Failed to parse accountKey');
|
||||
}
|
||||
initAcme();
|
||||
}
|
||||
} else {
|
||||
makeAccountKeyPair();
|
||||
}
|
||||
|
||||
function makeAccountKeyPair(save) {
|
||||
var keypair;
|
||||
log('Generating account keypair...');
|
||||
keypair=pki.rsa.generateKeyPair(2048);
|
||||
state.accountKeyPEM=pki.privateKeyToPem(keypair.privateKey);
|
||||
state.accountKeyPair=cryptoUtil.importPemPrivateKey(state.accountKeyPEM);
|
||||
if (save) {
|
||||
try {
|
||||
fs.writeFileSync(options.accountKey, state.accountKeyPEM);
|
||||
} catch(err) {
|
||||
return handleErr(err, 'Failed to save accountKey');
|
||||
}
|
||||
}
|
||||
initAcme();
|
||||
}
|
78
lib/cli.js
78
lib/cli.js
|
@ -1,78 +0,0 @@
|
|||
#!/usr/local/bin/node
|
||||
var app=require('commander'), letiny=require('./client'), examples=[
|
||||
'letiny -e me@example.com -w /var/www/example.com -d example.com --agree',
|
||||
'letiny -e me@example.com -m -d example.com -c cert.pem -k key.pem -i ca.pem --agree',
|
||||
'letiny -e me@example.com -m -d example.com,www.example.com --agree',
|
||||
'letiny --email me@example.com --webroot ./ --domains example.com --agree'
|
||||
];
|
||||
|
||||
app
|
||||
.option('-e, --email <email>', 'your email address')
|
||||
.option('-w, --webroot <path>', 'path for webroot verification OR')
|
||||
.option('-m, --manual', 'use manual verification')
|
||||
.option('-d, --domains <domains>', 'domains (comma seperated)')
|
||||
.option('-c, --cert <path>', 'path to save your certificate (cert.pem)')
|
||||
.option('-k, --key <path>', 'path to save your private key (privkey.pem)')
|
||||
.option('-i, --ca <path>', 'path to save issuer certificate (cacert.pem)')
|
||||
.option('-a, --account <path>', 'path of the account key (optional)')
|
||||
.option('--pfx <path>', 'path to save PKCS#12 certificate (optional)')
|
||||
.option('--password <password>', 'password for PKCS#12 certificate (optional)')
|
||||
.option('--aes', 'use AES instead of 3DES for PKCS#12')
|
||||
.option('--agree', 'agree terms of the ACME CA (required)')
|
||||
.option('--newreg <URL>', 'optional AMCE server newReg URL')
|
||||
.option('--debug', 'print debug information')
|
||||
.on('--help', function() {
|
||||
console.log(' Examples:\n\n '+examples.join('\n ')+'\n');
|
||||
})
|
||||
.parse(process.argv);
|
||||
|
||||
if (app.rawArgs.length<=2) {
|
||||
return app.parse(['', '', '-h']);
|
||||
} else if (!app.webroot && !app.manual) {
|
||||
return console.log('Error: You need to use "--manual" or "--webroot <path>"');
|
||||
} else if (!app.domains) {
|
||||
return console.log('Error: You need to specify "--domains <domain>"');
|
||||
} else if (!app.email) {
|
||||
return console.log('Error: You need to specify your "--email <address>"');
|
||||
} else if (!app.agree) {
|
||||
return console.log('Error: You need to "--agree" the terms');
|
||||
}
|
||||
|
||||
console.log('Generating keys and requesting certificate...');
|
||||
|
||||
letiny.getCert({
|
||||
email:app.email,
|
||||
domains:app.domains,
|
||||
webroot:app.webroot,
|
||||
challenge:manualVerification,
|
||||
certFile:app.cert || (app.pfx ? false : 'cert.pem'),
|
||||
keyFile:app.key || (app.pfx ? false : 'privkey.pem'),
|
||||
caFile:app.ca || (app.pfx ? false : 'cacert.pem'),
|
||||
accountKey:app.account,
|
||||
pfxFile:app.pfx,
|
||||
pfxPassword:app.password,
|
||||
aes:app.aes,
|
||||
newReg:app.newreg,
|
||||
agreeTerms:app.agree,
|
||||
debug:app.debug
|
||||
}, function(err, cert, key, cacert) {
|
||||
if (!err && cert && key && cacert) {
|
||||
console.log('Files successfully saved.');
|
||||
process.exit(0);
|
||||
}
|
||||
console.error('Error: ', err.stack || err || 'Something went wrong...');
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
function manualVerification(domain, path, data, done) {
|
||||
var rl=require('readline').createInterface({
|
||||
input:process.stdin,
|
||||
output:process.stdout
|
||||
});
|
||||
console.log('\nCreate this file: http://'+domain+path);
|
||||
console.log(' containing this: '+data+'\n');
|
||||
rl.question('Press ENTER when done or Ctrl+C to exit\n', function() {
|
||||
rl.close();
|
||||
done();
|
||||
});
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
if (~process.argv.indexOf('--letiny-fork')) {
|
||||
process.on('message', function(msg) {
|
||||
if (msg.request) {
|
||||
getCert(msg.request.options, function(err, cert, key, ca) {
|
||||
process.send({
|
||||
result:{
|
||||
err:err ? err.stack : null,
|
||||
cert:cert,
|
||||
key:key,
|
||||
ca:ca
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
if (options.certFile) {
|
||||
fs.writeFileSync(options.certFile, cert);
|
||||
}
|
||||
if (options.keyFile) {
|
||||
fs.writeFileSync(options.keyFile, state.certPrivateKeyPEM);
|
||||
}
|
||||
if (options.caFile) {
|
||||
fs.writeFileSync(options.caFile, state.caCert);
|
||||
}
|
||||
if (options.pfxFile) {
|
||||
try {
|
||||
pfx=forge.pkcs12.toPkcs12Asn1(
|
||||
pki.privateKeyFromPem(state.certPrivateKeyPEM),
|
||||
[pki.certificateFromPem(cert), pki.certificateFromPem(state.caCert)],
|
||||
options.pfxPassword || '',
|
||||
options.aes ? {} : {algorithm:'3des'}
|
||||
);
|
||||
pfx=new Buffer(forge.asn1.toDer(pfx).toHex(), 'hex');
|
||||
} catch(err) {
|
||||
handleErr(err, 'Could not convert to PKCS#12');
|
||||
}
|
||||
fs.writeFileSync(options.pfxFile, pfx);
|
||||
}
|
Loading…
Reference in New Issue