Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashmate): various ZeroSSL cert verification errors #2339

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,54 @@ export default function obtainZeroSSLCertificateTaskFactory(
skip: (ctx) => ctx.certificate && !['pending_validation', 'draft'].includes(ctx.certificate.status),
task: async (ctx, task) => {
let retry;
let autoRetryCount = 0;
const MAX_AUTO_RETRIES = 3; // Adjust based on requirements
do {
try {
await verifyDomain(ctx.certificate.id, ctx.apiKey);
} catch (e) {
if (ctx.noRetry !== true) {
retry = await task.prompt({
type: 'toggle',
header: chalk` An error occurred during verification: {red ${e.message}}
// Error: The given certificate is not ready for domain verification
// Sometimes this error means that certificate is already verified
if (e.code === 2831) {
const certificate = await getCertificate(ctx.apiKey, ctx.certificate.id);
// Just proceed on certificate download if we see it's already issued.
if (certificate.status === 'issued') {
return;
}
}

if (e.type === 'domain_control_validation_failed') {
// Retry on this undocumented error whatever it means
if (autoRetryCount >= MAX_AUTO_RETRIES) {
throw e;
}
autoRetryCount++;
if (process.env.DEBUG) {
// eslint-disable-next-line no-console
console.warn(`Retry ${autoRetryCount}/${MAX_AUTO_RETRIES} verification due to domain_control_validation_failed error`);
}
await wait(5000);
} else {
if (ctx.noRetry !== true) {
retry = await task.prompt({
type: 'toggle',
header: chalk` An error occurred during verification: {red ${e.message}}

Please ensure that port 80 on your public IP address ${ctx.externalIp} is open
for incoming HTTP connections. You may need to configure your firewall to
ensure this port is accessible from the public internet. If you are using
Network Address Translation (NAT), please enable port forwarding for port 80
and all Dash service ports listed above.`,
message: 'Try again?',
enabled: 'Yes',
disabled: 'No',
initial: true,
});
}
message: 'Try again?',
enabled: 'Yes',
disabled: 'No',
initial: true,
});
}

if (!retry) {
throw e;
if (!retry) {
throw e;
}
}
}
} while (retry);
Expand Down
Loading