fix(socket): set customize_hostname_check for TLS wildcard matching - #60
Merged
hpopp merged 1 commit intoJul 1, 2026
Merged
Conversation
The :https socket options enable verify: :verify_peer but never set
customize_hostname_check. Without it, OTP's default hostname matcher
compares DNS names by literal equality and skips RFC 6125 wildcard
matching, so a server presenting a wildcard SAN (e.g. *.googleapis.com)
is rejected against a concrete host (fcm.googleapis.com) with
{:bad_cert, {:hostname_check_failed, ...}}, killing the connection at boot.
Add the HTTPS match_fun (public_key.pkix_verify_hostname_match_fun(:https))
so wildcard certificates verify correctly. Caller-supplied :ssl opts still
win, since ssl honors the first occurrence of an option and caller opts
are prepended.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
|
Thanks for this! Let me get a release out. |
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.
Summary
Kadabra.Socketopens:httpsconnections withverify: :verify_peerbut never setscustomize_hostname_check. Without it, OTP's default hostname matcher compares DNS names by literal equality and skips RFC 6125 wildcard matching, so a server presenting only a wildcard SAN (e.g.*.googleapis.com) for a concrete host (fcm.googleapis.com) is rejected and the TLS handshake fails — fatal at boot for anything opening a Kadabra connection in its supervision tree (e.g. Pigeon's FCM dispatcher).Impact
We use Kadabra via Pigeon for FCM push notifications. Around 05:45 CEST Google began serving an
fcm.googleapis.comedge cert whose only matching SAN is the wildcard*.googleapis.com(no exact entry). Every connection then crashed at startup:*.googleapis.comcovers the requested host, but the default matcher refuses the wildcard.Fix
Add the HTTPS match_fun to the default
:httpsoptions:pkix_verify_hostname_match_fun(:https)is the only thing that routes DNS pairs into wildcard matching; ssl uses it solely viacustomize_hostname_check. Caller:sslopts still win — they're prepended and:sslhonors the first occurrence.Verification
*.googleapis.comcert:pkix_verify_hostname/2returnsfalsewith the default matcher,truewithpkix_verify_hostname_match_fun(:https).mix testgreen on pinned toolchain (Elixir 1.19 / OTP 28): 47 doctests, 24 tests, 0 failures.