diff --git a/configure b/configure index 745b5b7b91..c7185e3094 100755 --- a/configure +++ b/configure @@ -4689,7 +4689,8 @@ enabled omx && { check_header OMX_Core.h || add_cflags -isystem/opt/vc/include/IL ; } check_header OMX_Core.h ; } || die "ERROR: OpenMAX IL headers not found"; } -enabled openssl && { check_pkg_config openssl openssl/ssl.h SSL_library_init && { +enabled openssl && { { check_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl || + check_pkg_config openssl openssl/ssl.h SSL_library_init; } && { add_cflags $openssl_cflags && add_extralibs $openssl_libs; }|| check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto || check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 || diff --git a/libavformat/tls_openssl.c b/libavformat/tls_openssl.c index a75674e31f..4d94774355 100644 --- a/libavformat/tls_openssl.c +++ b/libavformat/tls_openssl.c @@ -43,6 +43,9 @@ typedef struct TLSContext { TLSShared tls_shared; SSL_CTX *ctx; SSL *ssl; +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + BIO_METHOD* url_bio_method; +#endif } TLSContext; #if HAVE_THREADS @@ -121,15 +124,25 @@ 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 (c->url_bio_method) + BIO_meth_free(c->url_bio_method); +#endif ff_openssl_deinit(); return 0; } static int url_bio_create(BIO *b) { +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + BIO_set_init(b, 1); + BIO_set_data(b, NULL); + BIO_set_flags(b, 0); +#else b->init = 1; b->ptr = NULL; b->flags = 0; +#endif return 1; } @@ -138,9 +151,15 @@ static int url_bio_destroy(BIO *b) return 1; } +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL +#define GET_BIO_DATA(x) BIO_get_data(x); +#else +#define GET_BIO_DATA(x) (x)->ptr; +#endif + static int url_bio_bread(BIO *b, char *buf, int len) { - URLContext *h = b->ptr; + URLContext *h = GET_BIO_DATA(b); int ret = ffurl_read(h, buf, len); if (ret >= 0) return ret; @@ -152,7 +171,7 @@ static int url_bio_bread(BIO *b, char *buf, int len) static int url_bio_bwrite(BIO *b, const char *buf, int len) { - URLContext *h = b->ptr; + URLContext *h = GET_BIO_DATA(b); int ret = ffurl_write(h, buf, len); if (ret >= 0) return ret; @@ -176,6 +195,7 @@ static int url_bio_bputs(BIO *b, const char *str) return url_bio_bwrite(b, str, strlen(str)); } +#if OPENSSL_VERSION_NUMBER < 0x1010000fL static BIO_METHOD url_bio_method = { .type = BIO_TYPE_SOURCE_SINK, .name = "urlprotocol bio", @@ -187,6 +207,7 @@ static BIO_METHOD url_bio_method = { .create = url_bio_create, .destroy = url_bio_destroy, }; +#endif static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options) { @@ -230,8 +251,20 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op ret = AVERROR(EIO); goto fail; } +#if OPENSSL_VERSION_NUMBER >= 0x1010000fL + 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); + BIO_meth_set_puts(p->url_bio_method, url_bio_bputs); + BIO_meth_set_ctrl(p->url_bio_method, url_bio_ctrl); + BIO_meth_set_create(p->url_bio_method, url_bio_create); + BIO_meth_set_destroy(p->url_bio_method, url_bio_destroy); + bio = BIO_new(p->url_bio_method); + BIO_set_data(bio, c->tcp); +#else bio = BIO_new(&url_bio_method); bio->ptr = c->tcp; +#endif SSL_set_bio(p->ssl, bio, bio); if (!c->listen && !c->numerichost) SSL_set_tlsext_host_name(p->ssl, c->host);