Skip to content

Commit b382594

Browse files
committed
ssl: fix NPN support
As of commit 4eb4b32 ("Remove support for OpenSSL 0.9.8 and 1.0.0", 2016-11-30), ext/openssl/extconf.rb don't check for existence of SSL_CTX_set_next_proto_select_cb() function, but the code still refers to the HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB macro. NPN is available in all supported versions of OpenSSL and LibreSSL, unless it's disabled by their configure options. Check OPENSSL_NO_NEXTPROTONEG macro instead.
1 parent d05a1a9 commit b382594

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ext/openssl/ossl_ssl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ ssl_renegotiation_cb(const SSL *ssl)
582582
(void) rb_funcall(cb, rb_intern("call"), 1, ssl_obj);
583583
}
584584

585-
#if defined(HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB) || \
585+
#if !defined(OPENSSL_NO_NEXTPROTONEG) || \
586586
defined(HAVE_SSL_CTX_SET_ALPN_SELECT_CB)
587587
static VALUE
588588
ssl_npn_encode_protocol_i(VALUE cur, VALUE encoded)
@@ -667,7 +667,7 @@ ssl_npn_select_cb_common(SSL *ssl, VALUE cb, const unsigned char **out,
667667
}
668668
#endif
669669

670-
#ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
670+
#ifndef OPENSSL_NO_NEXTPROTONEG
671671
static int
672672
ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen,
673673
void *arg)
@@ -881,7 +881,7 @@ ossl_sslctx_setup(VALUE self)
881881
val = rb_attr_get(self, id_i_verify_depth);
882882
if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2INT(val));
883883

884-
#ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
884+
#ifndef OPENSSL_NO_NEXTPROTONEG
885885
val = rb_attr_get(self, id_i_npn_protocols);
886886
if (!NIL_P(val)) {
887887
VALUE encoded = ssl_encode_npn_protocols(val);
@@ -2164,7 +2164,7 @@ ossl_ssl_get_client_ca_list(VALUE self)
21642164
return ossl_x509name_sk2ary(ca);
21652165
}
21662166

2167-
# ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
2167+
# ifndef OPENSSL_NO_NEXTPROTONEG
21682168
/*
21692169
* call-seq:
21702170
* ssl.npn_protocol => String | nil
@@ -2473,7 +2473,7 @@ Init_ossl_ssl(void)
24732473
* end
24742474
*/
24752475
rb_attr(cSSLContext, rb_intern("renegotiation_cb"), 1, 1, Qfalse);
2476-
#ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
2476+
#ifndef OPENSSL_NO_NEXTPROTONEG
24772477
/*
24782478
* An Enumerable of Strings. Each String represents a protocol to be
24792479
* advertised as the list of supported protocols for Next Protocol
@@ -2656,7 +2656,7 @@ Init_ossl_ssl(void)
26562656
# ifdef HAVE_SSL_CTX_SET_ALPN_SELECT_CB
26572657
rb_define_method(cSSLSocket, "alpn_protocol", ossl_ssl_alpn_protocol, 0);
26582658
# endif
2659-
# ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
2659+
# ifndef OPENSSL_NO_NEXTPROTONEG
26602660
rb_define_method(cSSLSocket, "npn_protocol", ossl_ssl_npn_protocol, 0);
26612661
# endif
26622662
#endif

0 commit comments

Comments
 (0)