ustream-openssl: fix compilation with OPENSSL_NO_DEPRECATED
[project/ustream-ssl.git] / ustream-openssl.c
index 3d576be1cf9397adf812bc03f1c87fa4096f9678..b357ebce150c5e5e250b162f8ad1ec94f8e656e3 100644 (file)
@@ -245,13 +245,18 @@ __hidden void __ustream_ssl_context_free(struct ustream_ssl_ctx *ctx)
        free(ctx);
 }
 
        free(ctx);
 }
 
-void __ustream_ssl_session_free(void *ssl)
+__hidden void __ustream_ssl_session_free(struct ustream_ssl *us)
 {
 {
-       BIO *bio = SSL_get_wbio(ssl);
-       struct bio_ctx *ctx = BIO_get_data(bio);
+       BIO *bio = SSL_get_wbio(us->ssl);
+       struct bio_ctx *ctx;
 
 
-       SSL_shutdown(ssl);
-       SSL_free(ssl);
+       SSL_shutdown(us->ssl);
+       SSL_free(us->ssl);
+
+       if (!us->conn)
+               return;
+
+       ctx = BIO_get_data(bio);
        if (ctx) {
                BIO_meth_free(ctx->meth);
                free(ctx);
        if (ctx) {
                BIO_meth_free(ctx->meth);
                free(ctx);
@@ -296,7 +301,11 @@ static void ustream_ssl_verify_cert(struct ustream_ssl *us)
                return;
        }
 
                return;
        }
 
+#if defined(HAVE_WOLFSSL)
        cert = SSL_get_peer_certificate(ssl);
        cert = SSL_get_peer_certificate(ssl);
+#else
+       cert = SSL_get1_peer_certificate(ssl);
+#endif
        if (!cert)
                return;
 
        if (!cert)
                return;