From patchwork Fri Jan 27 21:42:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 2343 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp440363vsb; Fri, 27 Jan 2017 13:42:46 -0800 (PST) X-Received: by 10.223.138.220 with SMTP id z28mr9141111wrz.26.1485553366106; Fri, 27 Jan 2017 13:42:46 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id v20si7341343wrc.50.2017.01.27.13.42.45; Fri, 27 Jan 2017 13:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@blackhole.sk; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E4FCE68AA5E; Fri, 27 Jan 2017 23:42:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-proxyout-31.websupport.sk (mail-proxyout-mua-31.websupport.sk [37.9.172.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53B8F68A0F7 for ; Fri, 27 Jan 2017 23:42:36 +0200 (EET) Received: from mail-proxyout-31.websupport.sk (localhost [127.0.0.1]) by mua-smtp-cf.websupport.sk (Postfix) with ESMTP id E10B3BDF95; Fri, 27 Jan 2017 22:42:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackhole.sk; s=mail; t=1485553356; bh=+TBWwobVG0J1VzwQChw9vVJepsYDGVq5Ta+V4Wdr0KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qqSwN5tOoCJPlIBCl6fyuegh3QhQMZsHOU9eNeVH94DeAeDOYZkHYPqy4BRAgsnaL T2A1kcTcyoLCRCogIsq3l8aODMrKPWFc1llWNXenbpn3S7T4o9ZWgjmESYi5U/ZU+Y 8JVqtAnq3obftU32yHRajgvj6w2oDCq5FTf63PyE= Received: from lb-proxy-12.websupport.sk (unknown [10.10.1.12]) by mail-proxyout-31.websupport.sk (Postfix) with ESMTP id D1E08BDF91; Fri, 27 Jan 2017 22:42:36 +0100 (CET) Received: from lb-proxy-12 (localhost [127.0.0.1]) by smtp-cf.websupport.sk (Postfix) with ESMTP id 3v9C1m5ZvXz5qnL; Fri, 27 Jan 2017 22:42:36 +0100 (CET) Received: from localhost.localdomain (otava-0452.koleje.cuni.cz [78.128.181.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kabel@blackhole.sk) by lb-proxy-12.websupport.sk (Postfix) with ESMTPSA; Fri, 27 Jan 2017 22:42:36 +0100 (CET) From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 27 Jan 2017 22:42:10 +0100 Message-Id: <20170127214210.13422-1-kabel@blackhole.sk> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: X-ESET-AntiSpam: OK;2;calc;2017-01-27 22:42:36;1701272242361007;33D7: X-Spam-Status: No, score=-1.0 required=100.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.1: X-Virus-Scanned: ClamAV using ClamSMTP Subject: [FFmpeg-devel] [PATCH] lavf/tls_openssl: Support building with LibreSSL X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Mark Thompson MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" In configure, check if the function BIO_meth_new is defined in the corresponding OpenSSL/LibreSSL library, and if yes, define HAVE_OPENSSL_BIO_METH_CALLS variable to 1 in config.h, or to 0 otherwise. Change the heuristics preprocessor check #if OPENSSL_VERSION_NUMBER >= 0x1010000fL to #if HAVE_OPENSSL_BIO_METH_CALLS This makes it possible to use LibreSSL, which defines OPENSSL_VERSION_NUMBER to >= 0x2000000fL, but does not support the BIO_meth_* calls from OpenSSL 1.1.0+. Signed-off-by: Marek Behun --- configure | 9 ++++++++- libavformat/tls_openssl.c | 12 ++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/configure b/configure index 7154142..f2bf7b4 100755 --- a/configure +++ b/configure @@ -2060,6 +2060,7 @@ HAVE_LIST=" makeinfo makeinfo_html MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS + openssl_bio_meth_calls perl pod2man sdl2 @@ -5883,7 +5884,13 @@ enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 || - die "ERROR: openssl not found"; } + die "ERROR: openssl not found"; } && + { { check_pkg_config openssl openssl/bio.h BIO_meth_new || + check_func BIO_meth_new -lssl -lcrypto || + check_func BIO_meth_new -lssl32 -leay32 || + check_func BIO_meth_new -lssl -lcrypto -lws2_32 -lgdi32; } && + enable openssl_bio_meth_calls || disable openssl_bio_meth_calls + } enabled qtkit_indev && { check_header_objcc QTKit/QTKit.h || disable qtkit_indev; } # libdc1394 check diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index 3d9768a..cede0b6 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -43,7 +43,7 @@ typedef struct TLSContext { TLSShared tls_shared; SSL_CTX *ctx; SSL *ssl; -#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#if HAVE_OPENSSL_BIO_METH_CALLS BIO_METHOD* url_bio_method; #endif } TLSContext; @@ -68,7 +68,7 @@ static unsigned long openssl_thread_id(void) static int url_bio_create(BIO *b) { -#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#if HAVE_OPENSSL_BIO_METH_CALLS BIO_set_init(b, 1); BIO_set_data(b, NULL); BIO_set_flags(b, 0); @@ -85,7 +85,7 @@ static int url_bio_destroy(BIO *b) return 1; } -#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#if HAVE_OPENSSL_BIO_METH_CALLS #define GET_BIO_DATA(x) BIO_get_data(x); #else #define GET_BIO_DATA(x) (x)->ptr; @@ -133,7 +133,7 @@ static int url_bio_bputs(BIO *b, const char *str) return url_bio_bwrite(b, str, strlen(str)); } -#if OPENSSL_VERSION_NUMBER < 0x1010000fL +#if !HAVE_OPENSSL_BIO_METH_CALLS static BIO_METHOD url_bio_method = { .type = BIO_TYPE_SOURCE_SINK, .name = "urlprotocol bio", @@ -212,7 +212,7 @@ static int tls_close(URLContext *h) SSL_CTX_free(c->ctx); if (c->tls_shared.tcp) ffurl_close(c->tls_shared.tcp); -#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#if HAVE_OPENSSL_BIO_METH_CALLS if (c->url_bio_method) BIO_meth_free(c->url_bio_method); #endif @@ -270,7 +270,7 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op ret = AVERROR(EIO); goto fail; } -#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#if HAVE_OPENSSL_BIO_METH_CALLS p->url_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "urlprotocol bio"); BIO_meth_set_write(p->url_bio_method, url_bio_bwrite); BIO_meth_set_read(p->url_bio_method, url_bio_bread);