diff options
| -rw-r--r-- | src/LibsslMessageDigestImpl.cc | 6 | ||||
| -rw-r--r-- | src/LibsslTLSSession.cc | 14 | ||||
| -rw-r--r-- | src/LibsslTLSSession.h | 1 | ||||
| -rw-r--r-- | src/libssl_compat.h | 43 | ||||
| -rw-r--r-- | test/Makefile.am | 2 |
5 files changed, 59 insertions, 7 deletions
diff --git a/src/LibsslMessageDigestImpl.cc b/src/LibsslMessageDigestImpl.cc index 15ebccbe..11c107f6 100644 --- a/src/LibsslMessageDigestImpl.cc +++ b/src/LibsslMessageDigestImpl.cc @@ -38,10 +38,11 @@ #include <openssl/evp.h> #include "Adler32MessageDigestImpl.h" +#include "libssl_compat.h" namespace aria2 { -#if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100001L +#if !OPENSSL_101_API namespace { EVP_MD_CTX* EVP_MD_CTX_new() { return EVP_MD_CTX_create(); } } // namespace @@ -57,8 +58,7 @@ int EVP_MD_CTX_reset(EVP_MD_CTX* ctx) return 1; } } // namespace -#endif // defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < - // 0x10100001L +#endif // !OPENSSL_101_API template <const EVP_MD* (*init_fn)()> class MessageDigestBase : public MessageDigestImpl { diff --git a/src/LibsslTLSSession.cc b/src/LibsslTLSSession.cc index 1014c3ca..f7024b1c 100644 --- a/src/LibsslTLSSession.cc +++ b/src/LibsslTLSSession.cc @@ -44,6 +44,15 @@ namespace aria2 { +#if !OPENSSL_101_API +namespace { +const unsigned char* ASN1_STRING_get0_data(ASN1_STRING* x) +{ + return ASN1_STRING_data(x); +} +} // namespace +#endif // !OPENSSL_101_API + TLSSession* TLSSession::make(TLSContext* ctx) { return new OpenSSLTLSSession(static_cast<OpenSSLTLSContext*>(ctx)); @@ -253,8 +262,7 @@ int OpenSSLTLSSession::tlsConnect(const std::string& hostname, for (size_t i = 0; i < n; ++i) { const GENERAL_NAME* altName = sk_GENERAL_NAME_value(altNames, i); if (altName->type == GEN_DNS) { - const char* name = - reinterpret_cast<char*>(ASN1_STRING_data(altName->d.ia5)); + auto name = ASN1_STRING_get0_data(altName->d.ia5); if (!name) { continue; } @@ -268,7 +276,7 @@ int OpenSSLTLSSession::tlsConnect(const std::string& hostname, continue; } } - dnsNames.push_back(std::string(name, len)); + dnsNames.push_back(std::string(name, name + len)); } else if (altName->type == GEN_IPADD) { const unsigned char* ipAddr = altName->d.iPAddress->data; diff --git a/src/LibsslTLSSession.h b/src/LibsslTLSSession.h index 5964aa21..7bc5a50c 100644 --- a/src/LibsslTLSSession.h +++ b/src/LibsslTLSSession.h @@ -42,6 +42,7 @@ #include "LibsslTLSContext.h" #include "TLSSession.h" #include "a2netcompat.h" +#include "libssl_compat.h" namespace aria2 { diff --git a/src/libssl_compat.h b/src/libssl_compat.h new file mode 100644 index 00000000..fa8e6f65 --- /dev/null +++ b/src/libssl_compat.h @@ -0,0 +1,43 @@ +/* <!-- copyright */ +/* + * aria2 - The high speed download utility + * + * Copyright (C) 2016 Tatsuhiro Tsujikawa + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. + */ +/* copyright --> */ +#ifndef LIBSSL_COMPAT_H +#define LIBSSL_COMPAT_H + +#include <openssl/opensslv.h> + +#define OPENSSL_101_API \ + (!defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x1010000fL) + +#endif // LIBSSL_COMPAT_H diff --git a/test/Makefile.am b/test/Makefile.am index 2315882f..48a962ec 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -243,7 +243,6 @@ endif # ENABLE_LIBARIA2 aria2c_LDADD = \ ../src/libaria2.la \ @LIBINTL@ \ - @CPPUNIT_LIBS@ \ @EXTRALIBS@ \ @ZLIB_LIBS@ \ @LIBUV_LIBS@ \ @@ -259,6 +258,7 @@ aria2c_LDADD = \ @LIBSSH2_LIBS@ \ @LIBCARES_LIBS@ \ @WSLAY_LIBS@ \ + @CPPUNIT_LIBS@ \ @TCMALLOC_LIBS@ \ @JEMALLOC_LIBS@ |
