diff --git a/Jamfile b/Jamfile index 3fdbfb575..a664d891e 100755 --- a/Jamfile +++ b/Jamfile @@ -73,7 +73,7 @@ rule linking ( properties * ) } # gcrypt libraries, if enabled - if gcrypt in $(properties) || openssl in $(properties) + if gcrypt in $(properties) { # on mac os x, adding the /opt/local/include path # would include openssl headers incompatible with diff --git a/include/libtorrent/ssl_stream.hpp b/include/libtorrent/ssl_stream.hpp index 673fcae62..0a7468ef6 100644 --- a/include/libtorrent/ssl_stream.hpp +++ b/include/libtorrent/ssl_stream.hpp @@ -69,7 +69,9 @@ public: void set_verify_callback(T const& fun, error_code& ec) { m_sock.set_verify_callback(fun, ec); } +#if BOOST_VERSION > 104600 SSL* native_handle() { return m_sock.native_handle(); } +#endif typedef boost::function handler_type; diff --git a/src/http_connection.cpp b/src/http_connection.cpp index e02973838..ec8be150f 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -42,7 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" #endif -#ifdef TORRENT_USE_OPENSSL +#if defined TORRENT_USE_OPENSSL && BOOST_VERSION > 104600 #include #endif @@ -340,7 +340,7 @@ void http_connection::start(std::string const& hostname, std::string const& port } } -#ifdef TORRENT_USE_OPENSSL +#if defined TORRENT_USE_OPENSSL && BOOST_VERSION > 104600 // for SSL connections, make sure to authenticate the hostname // of the certificate #define CASE(t) case socket_type_int_impl >::value: \ @@ -361,6 +361,8 @@ void http_connection::start(std::string const& hostname, std::string const& port , me, ec, (char*)0, 0)); return; } +#undef CASE + #endif #if TORRENT_USE_I2P diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 59292afda..1147e12fa 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -537,7 +537,7 @@ namespace aux { int session_impl::logging_allocator::allocated_bytes = 0; #endif -#ifdef TORRENT_USE_OPENSSL +#if defined TORRENT_USE_OPENSSL && BOOST_VERSION > 104600 // when running bittorrent over SSL, the SNI (server name indication) // extension is used to know which torrent the incoming connection is // trying to connect to. The 40 first bytes in the name is expected to @@ -684,8 +684,10 @@ namespace aux { error_code ec; #ifdef TORRENT_USE_OPENSSL m_ssl_ctx.set_verify_mode(asio::ssl::context::verify_none, ec); +#if BOOST_VERSION > 104600 SSL_CTX_set_tlsext_servername_callback(m_ssl_ctx.native_handle(), servername_callback); SSL_CTX_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this); +#endif // BOOST_VERSION #endif #ifndef TORRENT_DISABLE_DHT diff --git a/src/torrent.cpp b/src/torrent.cpp index db06a59ce..a44eea55a 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1477,7 +1477,7 @@ namespace libtorrent // tell the client we need a cert for this torrent alerts().post_alert(torrent_need_cert_alert(get_handle())); #else - set_error(asio::error::not_supported, "x.509 certificate"); + set_error(asio::error::operation_not_supported, "x.509 certificate"); pause(); #endif } @@ -4606,7 +4606,7 @@ namespace libtorrent str->set_dst_name(hostname); } -#ifdef TORRENT_USE_OPENSSL +#if defined TORRENT_USE_OPENSSL && BOOST_VERSION > 104600 // for SSL connections, make sure to authenticate the hostname // of the certificate #define CASE(t) case socket_type_int_impl >::value: \ @@ -4626,6 +4626,7 @@ namespace libtorrent m_ses.m_alerts.post_alert(url_seed_alert(get_handle(), web->url, ec)); return; } +#undef CASE #endif boost::intrusive_ptr c; @@ -5494,7 +5495,7 @@ namespace libtorrent (void)ret; TORRENT_ASSERT(ret); -#ifdef TORRENT_USE_OPENSSL +#if defined TORRENT_USE_OPENSSL && BOOST_VERSION > 104600 if (is_ssl_torrent()) { // for ssl sockets, set the hostname @@ -5512,6 +5513,7 @@ namespace libtorrent default: break; }; } +#undef CASE #endif } @@ -5644,6 +5646,7 @@ namespace libtorrent // INVARIANT_CHECK; #ifdef TORRENT_USE_OPENSSL +#if BOOST_VERSION > 104600 if (is_ssl_torrent()) { // if this is an SSL torrent, don't allow non SSL peers on it @@ -5684,6 +5687,13 @@ namespace libtorrent return false; } } +#else // BOOST_VERSION + if (is_ssl_torrent()) + { + p->disconnect(asio::error::operation_not_supported); + return false; + } +#endif #endif // TORRENT_USE_OPENSSL TORRENT_ASSERT(p != 0);