method
set_minmax_proto_version
ruby latest stable - Class:
OpenSSL::SSL::SSLContext
set_minmax_proto_version(p1, p2)private
Sets the minimum and maximum supported protocol versions. See #min_version= and #max_version=.
static VALUE
ossl_sslctx_set_minmax_proto_version(VALUE self, VALUE min_v, VALUE max_v)
{
SSL_CTX *ctx;
int min, max;
GetSSLCTX(self, ctx);
min = parse_proto_version(min_v);
max = parse_proto_version(max_v);
#ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
if (!SSL_CTX_set_min_proto_version(ctx, min))
ossl_raise(eSSLError, "SSL_CTX_set_min_proto_version");
if (!SSL_CTX_set_max_proto_version(ctx, max))
ossl_raise(eSSLError, "SSL_CTX_set_max_proto_version");
#else
{
unsigned long sum = 0, opts = 0;
int i;
static const struct {
int ver;
unsigned long opts;
} options_map[] = {
{ SSL2_VERSION, SSL_OP_NO_SSLv2 },
{ SSL3_VERSION, SSL_OP_NO_SSLv3 },
{ TLS1_VERSION, SSL_OP_NO_TLSv1 },
{ TLS1_1_VERSION, SSL_OP_NO_TLSv1_1 },
{ TLS1_2_VERSION, SSL_OP_NO_TLSv1_2 },
# if defined(TLS1_3_VERSION)
{ TLS1_3_VERSION, SSL_OP_NO_TLSv1_3 },
# endif
};
for (i = 0; i < numberof(options_map); i++) {
sum |= options_map[i].opts;
if (min && min > options_map[i].ver || max && max < options_map[i].ver)
opts |= options_map[i].opts;
}
SSL_CTX_clear_options(ctx, sum);
SSL_CTX_set_options(ctx, opts);
}
#endif
return Qnil;
} Related methods
- Instance methods
- add_certificate
- ciphers
- ciphers=
- ecdh_curves=
- enable_fallback_scsv
- flush_sessions
- freeze
- max_version=
- min_version=
- options
- options=
- security_level
- security_level=
- session_add
- session_cache_mode
- session_cache_mode=
- session_cache_size
- session_cache_size=
- session_cache_stats
- session_remove
- set_params
- setup
- ssl_version=
- Class methods
- new
- Private methods
-
set_minmax_proto_version