Add support for multiple domains on the command line
This commit is contained in:
parent
3596d6583a
commit
3f8c5ea000
|
|
@ -50,7 +50,7 @@ def run_test():
|
||||||
|
|
||||||
issue = subprocess.Popen('''
|
issue = subprocess.Popen('''
|
||||||
node test.js --email foo@bar.com --agree true \
|
node test.js --email foo@bar.com --agree true \
|
||||||
--domain foo.com --new-reg http://localhost:4300/acme/new-reg \
|
--domains foo.com --new-reg http://localhost:4300/acme/new-reg \
|
||||||
--certKey %s/key.pem --cert %s/cert.der
|
--certKey %s/key.pem --cert %s/cert.der
|
||||||
''' % (tempdir, tempdir), shell=True)
|
''' % (tempdir, tempdir), shell=True)
|
||||||
if issue.wait() != 0:
|
if issue.wait() != 0:
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ var cliOptions = cli.parse({
|
||||||
certFile: ["cert", "Path to output certificate (DER format)", "path", "cert.pem"],
|
certFile: ["cert", "Path to output certificate (DER format)", "path", "cert.pem"],
|
||||||
email: ["email", "Email address", "string", null],
|
email: ["email", "Email address", "string", null],
|
||||||
agreeTerms: ["agree", "Agree to terms of service", "boolean", null],
|
agreeTerms: ["agree", "Agree to terms of service", "boolean", null],
|
||||||
domain: ["domain", "Domain name for which to request a certificate", "string", null],
|
domains: ["domains", "Domain name(s) for which to request a certificate (comma-separated)", "string", null],
|
||||||
});
|
});
|
||||||
|
|
||||||
var state = {
|
var state = {
|
||||||
|
|
@ -111,7 +111,8 @@ var state = {
|
||||||
termsAgreed: null,
|
termsAgreed: null,
|
||||||
termsURL: null,
|
termsURL: null,
|
||||||
|
|
||||||
domain: cliOptions.domain,
|
haveCLIDomains: !!(cliOptions.domains),
|
||||||
|
domains: cliOptions.domains && cliOptions.domains.replace(/\s/g, "").split(/[^\w.-]+/),
|
||||||
validatedDomains: [],
|
validatedDomains: [],
|
||||||
validAuthorizationURLs: [],
|
validAuthorizationURLs: [],
|
||||||
|
|
||||||
|
|
@ -334,10 +335,10 @@ function sendAgreement(answers) {
|
||||||
console.log("Couldn't POST agreement back to server, aborting.");
|
console.log("Couldn't POST agreement back to server, aborting.");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
if (!state.domain) {
|
if (!state.domains || state.domains.length == 0) {
|
||||||
inquirer.prompt(questions.domain, getChallenges);
|
inquirer.prompt(questions.domain, getChallenges);
|
||||||
} else {
|
} else {
|
||||||
getChallenges({domain: state.domain});
|
getChallenges({domain: state.domains.pop()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -440,20 +441,24 @@ function ensureValidation(err, resp, body) {
|
||||||
state.validatedDomains.push(state.domain);
|
state.validatedDomains.push(state.domain);
|
||||||
state.validAuthorizationURLs.push(state.authorizationURL);
|
state.validAuthorizationURLs.push(state.authorizationURL);
|
||||||
|
|
||||||
// If we're doing this for a CLI-provided domain, only one
|
if (state.haveCLIDomains) {
|
||||||
// domain is supported; no need to loop back
|
console.log("have CLI domains: ");
|
||||||
if (cliOptions.domain) {
|
console.log(state.domains);
|
||||||
getCertificate();
|
if (state.haveCLIDomains && state.domains.length > 0) {
|
||||||
return;
|
getChallenges({domain: state.domains.pop()});
|
||||||
}
|
return;
|
||||||
|
|
||||||
inquirer.prompt(questions.anotherDomain, function(answers) {
|
|
||||||
if (answers.anotherDomain) {
|
|
||||||
inquirer.prompt(questions.domain, getChallenges);
|
|
||||||
} else {
|
} else {
|
||||||
getCertificate();
|
getCertificate();
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
inquirer.prompt(questions.anotherDomain, function(answers) {
|
||||||
|
if (answers.anotherDomain) {
|
||||||
|
inquirer.prompt(questions.domain, getChallenges);
|
||||||
|
} else {
|
||||||
|
getCertificate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (authz.status == "invalid") {
|
} else if (authz.status == "invalid") {
|
||||||
console.log("The CA was unable to validate the file you provisioned:" + body);
|
console.log("The CA was unable to validate the file you provisioned:" + body);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue