@@ -572,7 +572,7 @@ ssl_renegotiation_cb(const SSL *ssl)
572
572
(void ) rb_funcall (cb , rb_intern ("call" ), 1 , ssl_obj );
573
573
}
574
574
575
- #ifdef HAVE_OPENSSL_NPN_NEGOTIATED
575
+ #if defined( HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB ) || defined( HAVE_SSL_CTX_SET_ALPN_SELECT_CB )
576
576
static VALUE
577
577
ssl_npn_encode_protocol_i (VALUE cur , VALUE encoded )
578
578
{
@@ -596,18 +596,6 @@ ssl_npn_encode_protocols(VALUE sslctx, VALUE protocols)
596
596
rb_iv_set (sslctx , "@_protocols" , encoded );
597
597
}
598
598
599
- static int
600
- ssl_npn_advertise_cb (SSL * ssl , const unsigned char * * out , unsigned int * outlen , void * arg )
601
- {
602
- VALUE sslctx_obj = (VALUE ) arg ;
603
- VALUE protocols = rb_iv_get (sslctx_obj , "@_protocols" );
604
-
605
- * out = (const unsigned char * ) RSTRING_PTR (protocols );
606
- * outlen = RSTRING_LENINT (protocols );
607
-
608
- return SSL_TLSEXT_ERR_OK ;
609
- }
610
-
611
599
static int
612
600
ssl_npn_select_cb_common (VALUE cb , const unsigned char * * out , unsigned char * outlen , const unsigned char * in , unsigned int inlen )
613
601
{
@@ -640,6 +628,19 @@ ssl_npn_select_cb_common(VALUE cb, const unsigned char **out, unsigned char *out
640
628
return SSL_TLSEXT_ERR_OK ;
641
629
}
642
630
631
+ #ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
632
+ static int
633
+ ssl_npn_advertise_cb (SSL * ssl , const unsigned char * * out , unsigned int * outlen , void * arg )
634
+ {
635
+ VALUE sslctx_obj = (VALUE ) arg ;
636
+ VALUE protocols = rb_iv_get (sslctx_obj , "@_protocols" );
637
+
638
+ * out = (const unsigned char * ) RSTRING_PTR (protocols );
639
+ * outlen = RSTRING_LENINT (protocols );
640
+
641
+ return SSL_TLSEXT_ERR_OK ;
642
+ }
643
+
643
644
static int
644
645
ssl_npn_select_cb (SSL * s , unsigned char * * out , unsigned char * outlen , const unsigned char * in , unsigned int inlen , void * arg )
645
646
{
@@ -651,6 +652,7 @@ ssl_npn_select_cb(SSL *s, unsigned char **out, unsigned char *outlen, const unsi
651
652
return ssl_npn_select_cb_common (cb , (const unsigned char * * )out , outlen , in , inlen );
652
653
}
653
654
#endif
655
+ #endif /* HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB || HAVE_SSL_CTX_SET_ALPN_SELECT_CB */
654
656
655
657
/* This function may serve as the entry point to support further
656
658
* callbacks. */
@@ -783,7 +785,7 @@ ossl_sslctx_setup(VALUE self)
783
785
SSL_CTX_set_options (ctx , SSL_OP_ALL );
784
786
}
785
787
786
- #ifdef HAVE_OPENSSL_NPN_NEGOTIATED
788
+ #ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
787
789
val = rb_iv_get (self , "@npn_protocols" );
788
790
if (!NIL_P (val )) {
789
791
ssl_npn_encode_protocols (self , val );
@@ -1848,7 +1850,7 @@ ossl_ssl_get_client_ca_list(VALUE self)
1848
1850
return ossl_x509name_sk2ary (ca );
1849
1851
}
1850
1852
1851
- # ifdef HAVE_OPENSSL_NPN_NEGOTIATED
1853
+ # ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
1852
1854
/*
1853
1855
* call-seq:
1854
1856
* ssl.npn_protocol => String
@@ -2090,7 +2092,7 @@ Init_ossl_ssl()
2090
2092
* end
2091
2093
*/
2092
2094
rb_attr (cSSLContext , rb_intern ("renegotiation_cb" ), 1 , 1 , Qfalse );
2093
- #ifdef HAVE_OPENSSL_NPN_NEGOTIATED
2095
+ #ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
2094
2096
/*
2095
2097
* An Enumerable of Strings. Each String represents a protocol to be
2096
2098
* advertised as the list of supported protocols for Next Protocol
@@ -2234,7 +2236,7 @@ Init_ossl_ssl()
2234
2236
rb_define_method (cSSLSocket , "session=" , ossl_ssl_set_session , 1 );
2235
2237
rb_define_method (cSSLSocket , "verify_result" , ossl_ssl_get_verify_result , 0 );
2236
2238
rb_define_method (cSSLSocket , "client_ca" , ossl_ssl_get_client_ca_list , 0 );
2237
- # ifdef HAVE_OPENSSL_NPN_NEGOTIATED
2239
+ # ifdef HAVE_SSL_CTX_SET_NEXT_PROTO_SELECT_CB
2238
2240
rb_define_method (cSSLSocket , "npn_protocol" , ossl_ssl_npn_protocol , 0 );
2239
2241
# endif
2240
2242
#endif
0 commit comments