diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-18 16:47:21 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-12-21 16:58:43 +0900 |
commit | 528fae6f9e5f46dbf7e5871fbac1bb2e78c674fc (patch) | |
tree | a63c8dd2f08e7860323e1efafd99021af8020eaa /ext/openssl | |
parent | 1d94bc3a20e1fb7160f265e106e5c3c4502430b3 (diff) | |
download | ruby-openssl-528fae6f9e5f46dbf7e5871fbac1bb2e78c674fc.tar.gz |
ssl: use SSL_SESSION_get_protocol_version()
Restore the old behavior of OpenSSL::SSL::Session#==.
SSL_SESSION_get_protocol_version() was missing in OpenSSL master at the
time r55287 (cad3226a06a1, "openssl: adapt to OpenSSL 1.1.0 opaque
structs", 2016-06-05).
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/extconf.rb | 1 | ||||
-rw-r--r-- | ext/openssl/openssl_missing.h | 4 | ||||
-rw-r--r-- | ext/openssl/ossl_ssl_session.c | 9 |
3 files changed, 9 insertions, 5 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 73a458ba..7033b0e2 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -144,6 +144,7 @@ OpenSSL.check_func_or_macro("SSL_CTX_set_tmp_ecdh_callback", "openssl/ssl.h") # OpenSSL.check_func_or_macro("SSL_CTX_set_min_proto_version", "openssl/ssl.h") have_func("SSL_CTX_get_security_level") have_func("X509_get0_notBefore") +have_func("SSL_SESSION_get_protocol_version") Logging::message "=== Checking done. ===\n" diff --git a/ext/openssl/openssl_missing.h b/ext/openssl/openssl_missing.h index 1c289ebb..3d11aec2 100644 --- a/ext/openssl/openssl_missing.h +++ b/ext/openssl/openssl_missing.h @@ -258,4 +258,8 @@ IMPL_PKEY_GETTER(EC_KEY, ec) # define X509_CRL_get0_nextUpdate(x) X509_CRL_get_nextUpdate(x) #endif +#if !defined(HAVE_SSL_SESSION_GET_PROTOCOL_VERSION) +# define SSL_SESSION_get_protocol_version(s) ((s)->ssl_version) +#endif + #endif /* _OSSL_OPENSSL_MISSING_H_ */ diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c index 7abb8671..1b602a6c 100644 --- a/ext/openssl/ossl_ssl_session.c +++ b/ext/openssl/ossl_ssl_session.c @@ -93,23 +93,22 @@ ossl_ssl_session_initialize_copy(VALUE self, VALUE other) return self; } -#if HAVE_SSL_SESSION_CMP == 0 -int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b) +#if !defined(HAVE_SSL_SESSION_CMP) +int ossl_SSL_SESSION_cmp(const SSL_SESSION *a, const SSL_SESSION *b) { unsigned int a_len; const unsigned char *a_sid = SSL_SESSION_get_id(a, &a_len); unsigned int b_len; const unsigned char *b_sid = SSL_SESSION_get_id(b, &b_len); -#if !defined(HAVE_OPAQUE_OPENSSL) /* missing SSL_SESSION_get_ssl_version() ? */ - if (a->ssl_version != b->ssl_version) + if (SSL_SESSION_get_protocol_version(a) != SSL_SESSION_get_protocol_version(b)) return 1; -#endif if (a_len != b_len) return 1; return CRYPTO_memcmp(a_sid, b_sid, a_len); } +#define SSL_SESSION_cmp(a, b) ossl_SSL_SESSION_cmp(a, b) #endif /* |