Description
SSH host certificate verification currently requires an exact match between the requested hostname and a certificate principal. Host certificate principals may also contain wildcard characters, so a certificate principal such as *.example.com should match host.example.com.
According to the SSH documentation (ssh-keygen.1):
For host certificates, the principals specified using the -n argument are hostnames and may contain wildcard characters.
This behavior is supported by OpenSSH since version 10.3.
Current behavior
OpenSshCertificateHostKeyVerifier lowercases the hostname and checks it with:
principals.contains(principalName)
As a result, wildcard principals are rejected even when they match the hostname.
Expected behavior
Each allowed principal should be evaluated using the existing host wildcard matching logic. For example:
*.example.com should match host.example.com.
*.example.com should not match example.com.
- Existing exact principal matching should continue to work.
Proposed fix
Reuse HostKey.matchesWildcardPattern when checking certificate principals. I have the following patch, but I cannot push it:
support-wildcard-host-certificate-principals.patch
Acceptance criteria
- Host certificates with wildcard hostname principals are accepted when the requested hostname matches.
- Non-matching hostnames remain rejected.
- Exact hostname and IP-address principals continue to behave as before.
- Tests cover matching and non-matching wildcard principals.
Description
SSH host certificate verification currently requires an exact match between the requested hostname and a certificate principal. Host certificate principals may also contain wildcard characters, so a certificate principal such as
*.example.comshould matchhost.example.com.According to the SSH documentation (ssh-keygen.1):
This behavior is supported by OpenSSH since version 10.3.
Current behavior
OpenSshCertificateHostKeyVerifierlowercases the hostname and checks it with:As a result, wildcard principals are rejected even when they match the hostname.
Expected behavior
Each allowed principal should be evaluated using the existing host wildcard matching logic. For example:
*.example.comshould matchhost.example.com.*.example.comshould not matchexample.com.Proposed fix
Reuse
HostKey.matchesWildcardPatternwhen checking certificate principals. I have the following patch, but I cannot push it:support-wildcard-host-certificate-principals.patch
Acceptance criteria