1.0.2 to 1.1 migration problem with verify_callback()

Matt Caswell matt at openssl.org
Mon Aug 5 14:40:09 UTC 2019

On 02/08/2019 18:24, Neptune wrote:
> I am in the process of migrating our code from the 1.0.2 library to 1.1 and
> have run across a situation that I am struggling to reconcile:
> The existing code utilizes the verify_callback() function in order to
> perform validation measures against a peer certificate. This callback
> performs validation such as checking the certificate against a CRL and doing
> wildcard matching. The reason we need to define our own callback and
> validation code is because, as I understand it, the built-in OpenSSL
> wildcard matching will only process one wildcard field prefix (*.domain.com)
> whereas our requirements allow for wildcard patterns beyond just a prefix
> (FOO.*.domain.com, FOO.B*R.domain.com, etc.).
> The problem arises when I attempt to access 'ssl->tlsext_hostname' which is
> understood because this structure is now opaque. I believe the accessor
> function for this is '__owur const char *SSL_SESSION_get0_hostname(const
> SSL_SESSION *s);' in ssl.h. However, within the context of the callback
> function I only have two arguments to work with:
> int verify_callback(int ok, X509_STORE_CTX *ctx)
> This does not provide me with a SSL_SESSION object to pass into the
> SSL_SESSION_get0_hostname accessor function, so...

>From within your callback you can do this to get hold of the SSL object:

SSL *s = (SSL *)X509_STORE_CTX_get_ex_data(ctx,

And then this to get hold of the hostname requested:

const char *hostname = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);

Hope that helps,


More information about the openssl-users mailing list