summaryrefslogtreecommitdiff
path: root/libfetch
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2021-01-11 01:51:58 -0800
committerTimo Teräs <timo.teras@iki.fi>2021-01-27 09:13:07 +0200
commitc4c8aa5ba0ec6bf4c6d74c4807b66edfbd91be7c (patch)
treeb41da7bce64475790173cfd80366bb272a2f30ec /libfetch
parentbcbcbfc1fc9514db7a9ecddec5029b8d89fde5ed (diff)
downloadapk-tools-c4c8aa5ba0ec6bf4c6d74c4807b66edfbd91be7c.tar.gz
apk-tools-c4c8aa5ba0ec6bf4c6d74c4807b66edfbd91be7c.tar.bz2
apk-tools-c4c8aa5ba0ec6bf4c6d74c4807b66edfbd91be7c.tar.xz
apk-tools-c4c8aa5ba0ec6bf4c6d74c4807b66edfbd91be7c.zip
fix compilation without deprecated OpenSSL APIs
(De)initialization is deprecated under OpenSSL 1.0 and above. [TT: Some simplifications, and additional edits.] Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'libfetch')
-rw-r--r--libfetch/common.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/libfetch/common.c b/libfetch/common.c
index e91b0c6..bcba889 100644
--- a/libfetch/common.c
+++ b/libfetch/common.c
@@ -499,15 +499,11 @@ static int fetch_ssl_setup_client_certificate(SSL_CTX *ctx, int verbose)
int
fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
{
- /* Init the SSL library and context */
- if (!SSL_library_init()){
- fprintf(stderr, "SSL library init failed\n");
- return (-1);
- }
-
- SSL_load_error_strings();
-
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
conn->ssl_meth = SSLv23_client_method();
+#else
+ conn->ssl_meth = TLS_client_method();
+#endif
conn->ssl_ctx = SSL_CTX_new(conn->ssl_meth);
SSL_CTX_set_mode(conn->ssl_ctx, SSL_MODE_AUTO_RETRY);