Skip to content

fix: do not retry TLS certificate verification errors - #624

Merged
dwisiswant0 merged 1 commit into
mainfrom
tls-verify-no-retry
Nov 4, 2026
Merged

dwisiswant0 merged 1 commit into
mainfrom
tls-verify-no-retry

Conversation

@Mzack9999

Copy link
Copy Markdown
Member

Closes #623.

  • New isCertificateVerificationError: uses errors.As for *tls.CertificateVerificationError, x509.UnknownAuthorityError, x509.HostnameError and x509.CertificateInvalidError.
  • CheckRecoverableErrors returns no retry for these errors, wrapped in *url.Error or not.

Tests:

  • TestCheckRecoverableErrorsCertificateErrors: unknown authority, hostname mismatch, expired, bare and wrapped forms. main FAIL, branch PASS. A network error stays retryable.
  • TestDoDoesNotRetryCertificateErrors (local httptest TLS server, RetryMax: 3): main opens 4 connections for an untrusted certificate; branch opens 1. Hostname mismatch: 1 connection.
  • Package tests pass, except Test_DefaultHttpClient, which needs internet and was run without network (it fails the same way on main). go vet and golangci-lint: clean.

Behaviour change: a certificate verification error returns at once. Clients that skip verification (InsecureSkipVerify) do not change.

@dwisiswant0
dwisiswant0 merged commit 25f1220 into main Nov 4, 2026
7 checks passed
@dwisiswant0
dwisiswant0 deleted the tls-verify-no-retry branch November 4, 2026 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Certificate verification errors are retried

2 participants