fix(core): update
This commit is contained in:
parent
975c3ed190
commit
a8ab27045d
@ -13,14 +13,14 @@ export class SmartAcme {
|
|||||||
private privateKey: string;
|
private privateKey: string;
|
||||||
|
|
||||||
// challenge fullfillment
|
// challenge fullfillment
|
||||||
private setChallenge: (authz, challenge, keyAuthorization) => Promise<any>;
|
private setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>;
|
||||||
private removeChallenge: (authz, challenge, keyAuthorization) => Promise<any>;
|
private removeChallenge: (domainName: string) => Promise<any>;
|
||||||
|
|
||||||
public async init(optionsArg: {
|
public async init(optionsArg: {
|
||||||
accountPrivateKey?: string;
|
accountPrivateKey?: string;
|
||||||
accountEmail: string;
|
accountEmail: string;
|
||||||
setChallenge: (authz, challenge, keyAuthorization) => Promise<any>;
|
setChallenge: (domainName: string, keyAuthorization: string) => Promise<any>
|
||||||
removeChallenge: (authz, challenge, keyAuthorization) => Promise<any>;
|
removeChallenge: (domainName: string) => Promise<any>;
|
||||||
}) {
|
}) {
|
||||||
this.privateKey = optionsArg.accountPrivateKey || (await plugins.acme.forge.createPrivateKey());
|
this.privateKey = optionsArg.accountPrivateKey || (await plugins.acme.forge.createPrivateKey());
|
||||||
this.setChallenge = optionsArg.setChallenge;
|
this.setChallenge = optionsArg.setChallenge;
|
||||||
@ -49,25 +49,30 @@ export class SmartAcme {
|
|||||||
const authorizations = await this.client.getAuthorizations(order);
|
const authorizations = await this.client.getAuthorizations(order);
|
||||||
|
|
||||||
const promises = authorizations.map(async authz => {
|
const promises = authorizations.map(async authz => {
|
||||||
const challenge = authz.challenges.pop();
|
console.log(authz);
|
||||||
const keyAuthorization = await this.client.getChallengeKeyAuthorization(challenge);
|
const domainDnsName: string = `_acme-challenge.${authz.identifier.value}`;
|
||||||
|
const dnsChallenge: string = authz.challenges.find(challengeArg => {
|
||||||
|
return challengeArg.type === 'dns-01';
|
||||||
|
});
|
||||||
|
// process.exit(1);
|
||||||
|
const keyAuthorization: string = await this.client.getChallengeKeyAuthorization(dnsChallenge);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Satisfy challenge */
|
/* Satisfy challenge */
|
||||||
await this.setChallenge(authz, challenge, keyAuthorization);
|
await this.setChallenge(domainDnsName, keyAuthorization);
|
||||||
|
|
||||||
/* Verify that challenge is satisfied */
|
/* Verify that challenge is satisfied */
|
||||||
await this.client.verifyChallenge(authz, challenge);
|
await this.client.verifyChallenge(authz, dnsChallenge);
|
||||||
|
|
||||||
/* Notify ACME provider that challenge is satisfied */
|
/* Notify ACME provider that challenge is satisfied */
|
||||||
await this.client.completeChallenge(challenge);
|
await this.client.completeChallenge(dnsChallenge);
|
||||||
|
|
||||||
/* Wait for ACME provider to respond with valid status */
|
/* Wait for ACME provider to respond with valid status */
|
||||||
await this.client.waitForValidStatus(challenge);
|
await this.client.waitForValidStatus(dnsChallenge);
|
||||||
} finally {
|
} finally {
|
||||||
/* Clean up challenge response */
|
/* Clean up challenge response */
|
||||||
try {
|
try {
|
||||||
await this.removeChallenge(authz, challenge, keyAuthorization);
|
await this.removeChallenge(domainDnsName);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
@ -92,5 +97,5 @@ export class SmartAcme {
|
|||||||
console.log(`Certificate:\n${cert.toString()}`);
|
console.log(`Certificate:\n${cert.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
toStorageObject () {};
|
toStorageObject() {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user