--- src/openvpn/ssl_openssl.c.orig 2017-02-05 21:54:43.953909293 +0100 +++ src/openvpn/ssl_openssl.c 2017-02-05 22:39:01.467777228 +0100 @@ -507,10 +507,14 @@ const EC_GROUP *ecgrp = NULL; EVP_PKEY *pkey = NULL; - /* Little hack to get private key ref from SSL_CTX, yay OpenSSL... */ - SSL ssl; - ssl.cert = ctx->ctx->cert; - pkey = SSL_get_privatekey(&ssl); + /* Similar to what is done in curl: https://github.com/curl/curl/blob/master/lib/vtls/openssl.c#L603-L619 */ + SSL *ssl = SSL_new(ctx->ctx); + if (!ssl) + { + crypto_msg(M_FATAL, "SSL_new failed"); + } + pkey = SSL_get_privatekey(ssl); + SSL_free(ssl); msg(D_TLS_DEBUG, "Extracting ECDH curve from private key");