Can anyone confirm that the wildcard is removed by Indy or the OpenSSL libraries, although it is necessary to verify the host name?
No, OpenSSL does not delete it.
I do not know about the Indy library.
Can anyone confirm that the wildcard is removed by Indy or the OpenSSL libraries, although it is necessary to verify the host name?
I quote this twice for a reason :) Placing server names in Common Name (CN) is deprecated on both the IETF and the CA / B Forums (which browsers do).
What you are probably experiencing is similar to CN=example.com . In this case, example.com not the server name; rather it is domain Therefore, you should not assume that this means that it matches *.example.com .
And if the server responds to https://example.com , you should accept the certificate only if example.com specified as the alternative subject name, since the domains are listed in CN using public certificate authorities. Public CAs put DNS names in the SAN as they follow the CA / B forums.
Does anyone have an idea to check the hostname in these circumstances?
OpenSSL prior to 1.1.0 did not perform host name matching. The developer had to do this. OpenSSL 1.1.0 and higher has built-in functionality. See X509_check_host(3) and friends.
To match the host name, you must collect all the names from both the common name (CN) and the alternate topic name (SAN). Then its usually as simple as matching with a regular expression.
The IETFs are fast and free, and they allow you to display the host name in CN or SAN. The CA / B forum and browsers are more restrictive: if the hostname is in CN, it must also be present in the SAN (yes, it must be specified twice). Otherwise, the CA / B forum and browsers expect all host names in the SAN.
I believe that the OpenSSL and CA / B Forums only allow a wildcard on the leftmost label. I believe the IETF allows wildcards to be displayed anywhere.
If you want to see some sample code, then check out the cURL implementation. cURL uses OpenSSL, but does not depend on 1.1.0 X509_check_host(3) and friends. cURL has its own implementation.
Quick warning. Hostname matching is black art. For instance....
IETF allows you to map the global top-level domain (gTLD), for example *.com or *.net ; and a countryโs top-level domain (ccTLD), for example *.uk or *.us . I believe this is an attack because I know that there is no single certification authority that can claim to be "own" or "certify" gTLD. If I experience one of these certificates in the wild, I reject it.
CA / B forums do not allow gTLD or ccTLD wildcards. Browsers try to avoid this using the Public Suffix List (PSL). Things only got worse with areas of fuss, for example *.google .
There is one more thing that browsers are trying to do with PSL. They are trying to carve administrative boundaries into subdomains. For example, Amazon owns all amazon.com, but they delegate authority to subdomains, for example example.amazon.com. Thus, the PSL is trying to allow Amazon to manage its amazon.com domain, but not your seller related subdomain, example.amazon.com .
The IETF is trying to resolve administrative boundaries in the DBOUND workgroup . But the committee was stalled.