Skip to content

Commit 03a65d5

Browse files
committed
Add functions to get/set the max/min protocol version
1 parent 8db4667 commit 03a65d5

File tree

1 file changed

+38
-0
lines changed
  • source/deimos/openssl

1 file changed

+38
-0
lines changed

source/deimos/openssl/ssl.d

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,44 @@ auto SSL_CTX_clear_extra_chain_certs()(SSL_CTX* ctx, void* x509) {
18251825
return SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,null);
18261826
}
18271827

1828+
static if (OPENSSL_VERSION_AT_LEAST(1, 1, 0))
1829+
{
1830+
enum SSL_CTRL_SET_MIN_PROTO_VERSION = 123;
1831+
enum SSL_CTRL_SET_MAX_PROTO_VERSION = 124;
1832+
1833+
auto SSL_CTX_set_min_proto_version(SSL_CTX* ctx, int version_) {
1834+
return SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version_, null);
1835+
}
1836+
auto SSL_CTX_set_max_proto_version(SSL_CTX* ctx, int version_) {
1837+
return SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version_, null);
1838+
}
1839+
auto SSL_set_min_proto_version(SSL* s, int version_) {
1840+
return SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version_, null);
1841+
}
1842+
auto SSL_set_max_proto_version(SSL* s, int version_) {
1843+
return SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version_, null);
1844+
}
1845+
1846+
static if (OPENSSL_VERSION_AT_LEAST(1, 1, 1))
1847+
{
1848+
enum SSL_CTRL_GET_MIN_PROTO_VERSION = 130;
1849+
enum SSL_CTRL_GET_MAX_PROTO_VERSION = 131;
1850+
1851+
auto SSL_CTX_get_min_proto_version(SSL_CTX* ctx) {
1852+
return SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, null);
1853+
}
1854+
auto SSL_CTX_get_max_proto_version(SSL_CTX* ctx) {
1855+
return SSL_CTX_ctrl(ctx, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, null);
1856+
}
1857+
auto SSL_get_min_proto_version(SSL* s) {
1858+
return SSL_ctrl(s, SSL_CTRL_GET_MIN_PROTO_VERSION, 0, null);
1859+
}
1860+
auto SSL_get_max_proto_version(SSL* s) {
1861+
return SSL_ctrl(s, SSL_CTRL_GET_MAX_PROTO_VERSION, 0, null);
1862+
}
1863+
}
1864+
}
1865+
18281866
version(OPENSSL_NO_BIO) {} else {
18291867
BIO_METHOD* BIO_f_ssl();
18301868
BIO* BIO_new_ssl(SSL_CTX* ctx,int client);

0 commit comments

Comments
 (0)