|
@@ -384,7 +384,11 @@ tor_tls_init(void)
|
|
|
|
|
|
#if (SIZEOF_VOID_P >= 8 && \
|
|
#if (SIZEOF_VOID_P >= 8 && \
|
|
OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,0,1))
|
|
OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,0,1))
|
|
|
|
+#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0)
|
|
|
|
+ long version = OpenSSL_version_num();
|
|
|
|
+#else
|
|
long version = SSLeay();
|
|
long version = SSLeay();
|
|
|
|
+#endif
|
|
|
|
|
|
/* LCOV_EXCL_START : we can't test these lines on the same machine */
|
|
/* LCOV_EXCL_START : we can't test these lines on the same machine */
|
|
if (version >= OPENSSL_V_SERIES(1,0,1)) {
|
|
if (version >= OPENSSL_V_SERIES(1,0,1)) {
|
|
@@ -1525,7 +1529,6 @@ STATIC void
|
|
tor_tls_server_info_callback(const SSL *ssl, int type, int val)
|
|
tor_tls_server_info_callback(const SSL *ssl, int type, int val)
|
|
{
|
|
{
|
|
tor_tls_t *tls;
|
|
tor_tls_t *tls;
|
|
- int ssl_state;
|
|
|
|
(void) val;
|
|
(void) val;
|
|
|
|
|
|
tor_tls_debug_state_callback(ssl, type, val);
|
|
tor_tls_debug_state_callback(ssl, type, val);
|
|
@@ -1533,10 +1536,16 @@ tor_tls_server_info_callback(const SSL *ssl, int type, int val)
|
|
if (type != SSL_CB_ACCEPT_LOOP)
|
|
if (type != SSL_CB_ACCEPT_LOOP)
|
|
return;
|
|
return;
|
|
|
|
|
|
- ssl_state = SSL_state(ssl);
|
|
|
|
|
|
+#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0)
|
|
|
|
+ OSSL_HANDSHAKE_STATE ssl_state = SSL_get_state(ssl);
|
|
|
|
+ if (ssl_state == TLS_ST_SW_SRVR_HELLO)
|
|
|
|
+ return;
|
|
|
|
+#else
|
|
|
|
+ int ssl_state = SSL_state(ssl);
|
|
if ((ssl_state != SSL3_ST_SW_SRVR_HELLO_A) &&
|
|
if ((ssl_state != SSL3_ST_SW_SRVR_HELLO_A) &&
|
|
(ssl_state != SSL3_ST_SW_SRVR_HELLO_B))
|
|
(ssl_state != SSL3_ST_SW_SRVR_HELLO_B))
|
|
return;
|
|
return;
|
|
|
|
+#endif
|
|
tls = tor_tls_get_by_ssl(ssl);
|
|
tls = tor_tls_get_by_ssl(ssl);
|
|
if (tls) {
|
|
if (tls) {
|
|
/* Check whether we're watching for renegotiates. If so, this is one! */
|
|
/* Check whether we're watching for renegotiates. If so, this is one! */
|
|
@@ -1892,13 +1901,16 @@ int
|
|
tor_tls_handshake(tor_tls_t *tls)
|
|
tor_tls_handshake(tor_tls_t *tls)
|
|
{
|
|
{
|
|
int r;
|
|
int r;
|
|
- int oldstate;
|
|
|
|
tor_assert(tls);
|
|
tor_assert(tls);
|
|
tor_assert(tls->ssl);
|
|
tor_assert(tls->ssl);
|
|
tor_assert(tls->state == TOR_TLS_ST_HANDSHAKE);
|
|
tor_assert(tls->state == TOR_TLS_ST_HANDSHAKE);
|
|
|
|
|
|
check_no_tls_errors();
|
|
check_no_tls_errors();
|
|
- oldstate = SSL_state(tls->ssl);
|
|
|
|
|
|
+#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0)
|
|
|
|
+ OSSL_HANDSHAKE_STATE oldstate = SSL_get_state(tls->ssl);
|
|
|
|
+#else
|
|
|
|
+ int oldstate = SSL_state(tls->ssl);
|
|
|
|
+#endif
|
|
if (tls->isServer) {
|
|
if (tls->isServer) {
|
|
log_debug(LD_HANDSHAKE, "About to call SSL_accept on %p (%s)", tls,
|
|
log_debug(LD_HANDSHAKE, "About to call SSL_accept on %p (%s)", tls,
|
|
SSL_state_string_long(tls->ssl));
|
|
SSL_state_string_long(tls->ssl));
|
|
@@ -1908,7 +1920,12 @@ tor_tls_handshake(tor_tls_t *tls)
|
|
SSL_state_string_long(tls->ssl));
|
|
SSL_state_string_long(tls->ssl));
|
|
r = SSL_connect(tls->ssl);
|
|
r = SSL_connect(tls->ssl);
|
|
}
|
|
}
|
|
- if (oldstate != SSL_state(tls->ssl))
|
|
|
|
|
|
+#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,1,0)
|
|
|
|
+ OSSL_HANDSHAKE_STATE newstate = SSL_get_state(tls->ssl);
|
|
|
|
+#else
|
|
|
|
+ int newstate = SSL_state(tls->ssl);
|
|
|
|
+#endif
|
|
|
|
+ if (oldstate != newstate)
|
|
log_debug(LD_HANDSHAKE, "After call, %p was in state %s",
|
|
log_debug(LD_HANDSHAKE, "After call, %p was in state %s",
|
|
tls, SSL_state_string_long(tls->ssl));
|
|
tls, SSL_state_string_long(tls->ssl));
|
|
/* We need to call this here and not earlier, since OpenSSL has a penchant
|
|
/* We need to call this here and not earlier, since OpenSSL has a penchant
|