diff --git a/lib/client.js b/lib/client.js index f86bfff..6c99fa5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -104,6 +104,11 @@ Acme.prototype.post=function(url, body, cb) { function registerNewAccount(state, options, cb) { + var state = {}; + + if (!options.accountPrivateKeyPem) { + return handleErr(new Error("options.accountPrivateKeyPem must be an ascii private key pem")); + } if (!options.agreeToTerms) { cb(new Error("options.agreeToTerms must be function (tosUrl, fn => (err, true))")); return; @@ -117,6 +122,10 @@ function registerNewAccount(state, options, cb) { return; } + state.accountKeyPem=options.accountPrivateKeyPem; + state.accountKeyPair=cryptoUtil.importPemPrivateKey(state.accountKeyPEM); + state.acme=new Acme(state.accountKeyPair); + register(); function register() { @@ -216,7 +225,11 @@ function getCert(options, cb) { if (!options.removeChallenge) { return handleErr(new Error("options.removeChallenge must be function(hostname, challengeKey, done) {}")); } + if (!(options.domains && options.domains.length)) { + return handleErr(new Error("options.domains must be an array of domains such as ['example.com', 'www.example.com']")); + } + state.domains = options.domains.slice(0); // copy array try { state.accountKeyPem=options.accountPrivateKeyPem; state.accountKeyPair=cryptoUtil.importPemPrivateKey(state.accountKeyPEM);