@@ -662,32 +662,73 @@ enum SSL_MODE_SEND_SERVERHELLO_TIME = 0x00000040L;
662
662
/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
663
663
* they cannot be used to clear bits. */
664
664
665
- c_ulong SSL_CTX_get_options (const SSL_CTX * ctx);
666
- c_ulong SSL_get_options (const SSL * s);
667
- c_ulong SSL_CTX_clear_options (SSL_CTX * ctx, c_ulong op);
668
- c_ulong SSL_clear_options (SSL * s, c_ulong op);
669
- c_ulong SSL_CTX_set_options (SSL_CTX * ctx, c_ulong op);
670
- c_ulong SSL_set_options (SSL * s, c_ulong op);
671
-
672
- auto SSL_CTX_set_mode ()(SSL_CTX * ctx, c_long op) {
665
+ static if (OPENSSL_VERSION_AT_LEAST (1 , 1 , 0 ))
666
+ {
667
+ static if (OPENSSL_VERSION_AT_LEAST (3 , 0 , 0 ))
668
+ {
669
+ // The argument type for `SSL_[CTX_][gs]et_options was changed between 1.1.1
670
+ // and 3.0.0, from `c_long` to `uint64_t`. See below commit.
671
+ // https://github.com/openssl/openssl/commit/56bd17830f2d5855b533d923d4e0649d3ed61d11
672
+ private alias SSLOptionType = ulong ;
673
+ }
674
+ else
675
+ {
676
+ // Note: Despite the manuals listing the return type (as well as parameter)
677
+ // as 'long', the `.h` was `unsigned long`.
678
+ private alias SSLOptionType = c_ulong;
679
+ }
680
+ SSLOptionType SSL_CTX_get_options (const SSL_CTX * ctx);
681
+ SSLOptionType SSL_get_options (const SSL * ssl);
682
+ SSLOptionType SSL_CTX_clear_options (SSL_CTX * ctx, SSLOptionType op);
683
+ SSLOptionType SSL_clear_options (SSL * ssl, SSLOptionType op);
684
+ SSLOptionType SSL_CTX_set_options (SSL_CTX * ctx, SSLOptionType op);
685
+ SSLOptionType SSL_set_options (SSL * ssl, SSLOptionType op);
686
+ }
687
+ else
688
+ {
689
+ // Before v1.1.0, those were macros. See below commit.
690
+ // https://github.com/openssl/openssl/commit/8106cb8b6d706079cbcabd4631f05e4526a316e1
691
+ private alias SSLOptionType = c_ulong;
692
+
693
+ SSLOptionType SSL_CTX_set_options ()(SSL_CTX * ctx, SSLOptionType op) {
694
+ return SSL_CTX_ctrl (ctx, SSL_CTRL_OPTIONS , op, null );
695
+ }
696
+ SSLOptionType SSL_CTX_clear_options ()(SSL_CTX * ctx, SSLOptionType op) {
697
+ return SSL_CTX_ctrl (ctx, SSL_CTRL_CLEAR_OPTIONS , op, null );
698
+ }
699
+ SSLOptionType SSL_CTX_get_options ()(SSL_CTX * ctx) {
700
+ return SSL_CTX_ctrl (ctx, SSL_CTRL_OPTIONS , 0 , null );
701
+ }
702
+ SSLOptionType SSL_set_options ()(SSL * ssl, SSLOptionType op) {
703
+ return SSL_ctrl (ssl, SSL_CTRL_OPTIONS , op, null );
704
+ }
705
+ SSLOptionType SSL_clear_options ()(SSL * ssl, SSLOptionType op) {
706
+ return SSL_ctrl (ssl, SSL_CTRL_CLEAR_OPTIONS , op, null );
707
+ }
708
+ SSLOptionType SSL_get_options ()(SSL * ssl) {
709
+ return SSL_ctrl (ssl, SSL_CTRL_OPTIONS , 0 , null );
710
+ }
711
+ }
712
+
713
+ auto SSL_CTX_set_mode ()(SSL_CTX * ctx, SSLOptionType op) {
673
714
return SSL_CTX_ctrl (ctx,SSL_CTRL_MODE ,op,null );
674
715
}
675
- auto SSL_CTX_clear_mode ()(SSL_CTX * ctx, c_long op) {
716
+ auto SSL_CTX_clear_mode ()(SSL_CTX * ctx, SSLOptionType op) {
676
717
return SSL_CTX_ctrl (ctx,SSL_CTRL_CLEAR_MODE ,op,null );
677
718
}
678
719
auto SSL_CTX_get_mode ()(SSL_CTX * ctx) {
679
720
return SSL_CTX_ctrl (ctx,SSL_CTRL_MODE ,0 ,null );
680
721
}
681
- auto SSL_clear_mode ()(SSL * ssl, c_long op) {
722
+ auto SSL_clear_mode ()(SSL * ssl, SSLOptionType op) {
682
723
return SSL_ctrl (ssl,SSL_CTRL_CLEAR_MODE ,op,null );
683
724
}
684
- auto SSL_set_mode ()(SSL * ssl, c_long op) {
725
+ auto SSL_set_mode ()(SSL * ssl, SSLOptionType op) {
685
726
return SSL_ctrl (ssl,SSL_CTRL_MODE ,op,null );
686
727
}
687
728
auto SSL_get_mode ()(SSL * ssl) {
688
729
return SSL_ctrl (ssl,SSL_CTRL_MODE ,0 ,null );
689
730
}
690
- auto SSL_set_mtu ()(SSL * ssl, c_long mtu) {
731
+ auto SSL_set_mtu ()(SSL * ssl, SSLOptionType mtu) {
691
732
return SSL_ctrl (ssl,SSL_CTRL_MTU ,mtu,null );
692
733
}
693
734
@@ -898,7 +939,7 @@ struct ssl_ctx_st
898
939
899
940
/* Default values to use in SSL structures follow (these are copied by SSL_new) */
900
941
901
- c_ulong options;
942
+ SSLOptionType options;
902
943
c_ulong mode;
903
944
c_long max_cert_list;
904
945
@@ -1317,7 +1358,7 @@ version(OPENSSL_NO_PSK) {} else {
1317
1358
STACK_OF ! (X509_NAME ) * client_CA;
1318
1359
1319
1360
int references;
1320
- c_ulong options; /* protocol behaviour */
1361
+ SSLOptionType options; /* protocol behaviour */
1321
1362
c_ulong mode; /* API behaviour */
1322
1363
c_long max_cert_list;
1323
1364
int first_packet;
0 commit comments