Skip to content

Commit 1f590f3

Browse files
authored
Merge pull request #285 from guanqun/enhance-ssl-version
enhance 'ssl_version' to be able to set max version as well
2 parents 18c8961 + e92f2a6 commit 1f590f3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/easy/handle.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,11 @@ impl Easy {
953953
self.inner.ssl_version(version)
954954
}
955955

956+
/// Same as [`Easy2::ssl_min_max_version`](struct.Easy2.html#method.ssl_min_max_version)
957+
pub fn ssl_min_max_version(&mut self, min_version: SslVersion, max_version: SslVersion) -> Result<(), Error> {
958+
self.inner.ssl_min_max_version(min_version, max_version)
959+
}
960+
956961
/// Same as [`Easy2::ssl_verify_host`](struct.Easy2.html#method.ssl_verify_host)
957962
pub fn ssl_verify_host(&mut self, verify: bool) -> Result<(), Error> {
958963
self.inner.ssl_verify_host(verify)

src/easy/handler.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ pub enum HttpVersion {
467467
__Nonexhaustive = 500,
468468
}
469469

470-
/// Possible values to pass to the `ip_resolve` method.
470+
/// Possible values to pass to the `ssl_version` method.
471471
#[allow(missing_docs)]
472472
#[derive(Debug)]
473473
pub enum SslVersion {
@@ -1953,6 +1953,15 @@ impl<H> Easy2<H> {
19531953
self.setopt_long(curl_sys::CURLOPT_SSLVERSION, version as c_long)
19541954
}
19551955

1956+
/// Set preferred TLS/SSL version with minimum version and maximum version.
1957+
///
1958+
/// By default this option is not set and corresponds to
1959+
/// `CURLOPT_SSLVERSION`.
1960+
pub fn ssl_min_max_version(&mut self, min_version: SslVersion, max_version: SslVersion) -> Result<(), Error> {
1961+
let version = (min_version as c_long) | ((max_version as c_long) << 16);
1962+
self.setopt_long(curl_sys::CURLOPT_SSLVERSION, version)
1963+
}
1964+
19561965
/// Verify the certificate's name against host.
19571966
///
19581967
/// This should be disabled with great caution! It basically disables the

0 commit comments

Comments
 (0)