On Thu, May 26, 2016 at 10:45:54PM +0100, Matt Caswell wrote:

> > Using OpenSSL-1.0.x, I currently use:
> > 
> >   ssl_version = sess->ssl_version;
> > 
> > However, I don't see an equivalent accessor in the 1.1.x APIs.  Have I
> > missed something, or does such a thing not exist yet?
> 
> I don't think such a thing exists at the moment. Out of interest why do
> you need it?

The following should work:

    const char *get_session_protocol(SSL_CTX *ctx, SSL_SESSION *session)
    {
        const char *protocol;
        SSL_CTX *tmp_ctx = NULL;

        /* Typically you'd pass in a suitable non-NULL ctx */
        if (ctx == NULL)
            ctx = tmp_ctx = SSL_CTX_new(TLS_method());

        ssl = SSL_new(ctx);
        SSL_set_session(ssl, session);
        protocol = SSL_get_version(ssl);

        SSL_free(ssl);
        SSL_CTX_free(tmp_ctx);

        return protocol;
    }

-- 
        Viktor.
-- 
openssl-dev mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev

Reply via email to