config: add allow_incompatible_key_usage TLS option#900
Open
alliasgher wants to merge 2 commits intoprometheus:mainfrom
Open
config: add allow_incompatible_key_usage TLS option#900alliasgher wants to merge 2 commits intoprometheus:mainfrom
alliasgher wants to merge 2 commits intoprometheus:mainfrom
Conversation
added 2 commits
April 15, 2026 20:00
Let's Encrypt announced they will stop issuing certificates with the TLS Client Authentication Extended Key Usage (EKU) in 2026. Modern Go TLS rejects peer certificates that do not carry the expected EKU, causing failures in components that use the same LE certificate for both client and server roles (e.g. Alertmanager cluster/gossip mTLS). Add AllowIncompatibleKeyUsage to TLSConfig. When true the built-in EKU check is bypassed while the full certificate chain trust, expiry, and (on client connections) hostname verification are preserved. Implementation: setting InsecureSkipVerify=true prevents Go's TLS stack from running its EKU assertion, while a VerifyPeerCertificate callback re-implements the remaining checks with x509.ExtKeyUsageAny so the EKU field is accepted regardless of its value. The new bool serialises as allow_incompatible_key_usage in both YAML and JSON config files. Fixes prometheus/alertmanager#5151 Signed-off-by: Ali <alliasgher123@gmail.com>
Signed-off-by: Ali <alliasgher123@gmail.com>
Member
|
Hello, Thank you for this pull request which seems to fix something real. Can we use VerifyConnection instead? (pseudocode:) also add negative tests and tests with other hostnames would be great. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Let's Encrypt announced they will stop issuing certificates with the TLS Client Authentication Extended Key Usage (EKU) in 2026. Modern Go TLS strictly enforces EKU matching — it rejects client certificates that lack
ExtKeyUsageClientAuthand server certificates that lackExtKeyUsageServerAuth.This breaks components (notably Alertmanager cluster/gossip) that reuse the same LE certificate for both TLS server and client roles. The peer acting as a TLS server rejects the connecting peer's certificate with:
See: prometheus/alertmanager#5151
Solution
Add
allow_incompatible_key_usagetoTLSConfig:When set, the EKU check is skipped while the following security properties are preserved:
server_nameor SNI)insecure_skip_verifyremains unchanged and is not implied.Implementation
Go's TLS stack performs EKU verification internally and there is no supported hook to disable only that check. The workaround is:
InsecureSkipVerify = true— disables Go's built-in verification entirelyVerifyPeerCertificatecallback that re-implements the verification usingx509.VerifyOptions{KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageAny}}— accepts any EKU while still checking chain + expiry + hostnameThe callback captures the
*tls.Configpointer (not the field value) so that callers who setRootCAsafterNewTLSConfigreturns are still respected.Tests
TestTLSConfigAllowIncompatibleKeyUsage:clientAuthEKU (noserverAuth) — the EKU mismatch a TLS client would encounter with an LE cert used for mTLSincompatible key usage