Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1726311

Browse filesBrowse files
committed
minimum version
maximum version munmark tests
1 parent 1bfa121 commit 1726311
Copy full SHA for 1726311

File tree

Expand file treeCollapse file tree

2 files changed

+41
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+41
-2
lines changed
Open diff view settings
Collapse file

‎Lib/test/test_ssl.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_ssl.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,6 @@ def test_check_hostname_idn(self, warnings_filters=True):
32633263
server_hostname=b'k\xf6nig.idn.pythontest.net',
32643264
)
32653265

3266-
@unittest.expectedFailure # TODO: RUSTPYTHON
32673266
def test_wrong_cert_tls12(self):
32683267
"""Connecting when the server rejects the client's certificate
32693268
@@ -4042,7 +4041,6 @@ def test_min_max_version_sslv3(self):
40424041
s.connect((HOST, server.port))
40434042
self.assertEqual(s.version(), 'SSLv3')
40444043

4045-
@unittest.expectedFailure # TODO: RUSTPYTHON
40464044
def test_default_ecdh_curve(self):
40474045
# Issue #21015: elliptic curve-based Diffie Hellman key exchange
40484046
# should be enabled by default on SSL contexts.
Collapse file

‎stdlib/src/ssl.rs‎

Copy file name to clipboardExpand all lines: stdlib/src/ssl.rs
+41Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,47 @@ mod _ssl {
802802
self.check_hostname.store(ch);
803803
}
804804

805+
// PY_PROTO_MINIMUM_SUPPORTED = -2, PY_PROTO_MAXIMUM_SUPPORTED = -1
806+
#[pygetset]
807+
fn minimum_version(&self) -> i32 {
808+
let ctx = self.ctx();
809+
let version = unsafe { sys::SSL_CTX_get_min_proto_version(ctx.as_ptr()) };
810+
if version == 0 {
811+
-2 // PY_PROTO_MINIMUM_SUPPORTED
812+
} else {
813+
version
814+
}
815+
}
816+
#[pygetset(setter)]
817+
fn set_minimum_version(&self, value: i32, vm: &VirtualMachine) -> PyResult<()> {
818+
let ctx = self.builder();
819+
let result = unsafe { sys::SSL_CTX_set_min_proto_version(ctx.as_ptr(), value) };
820+
if result == 0 {
821+
return Err(vm.new_value_error("invalid protocol version"));
822+
}
823+
Ok(())
824+
}
825+
826+
#[pygetset]
827+
fn maximum_version(&self) -> i32 {
828+
let ctx = self.ctx();
829+
let version = unsafe { sys::SSL_CTX_get_max_proto_version(ctx.as_ptr()) };
830+
if version == 0 {
831+
-1 // PY_PROTO_MAXIMUM_SUPPORTED
832+
} else {
833+
version
834+
}
835+
}
836+
#[pygetset(setter)]
837+
fn set_maximum_version(&self, value: i32, vm: &VirtualMachine) -> PyResult<()> {
838+
let ctx = self.builder();
839+
let result = unsafe { sys::SSL_CTX_set_max_proto_version(ctx.as_ptr(), value) };
840+
if result == 0 {
841+
return Err(vm.new_value_error("invalid protocol version"));
842+
}
843+
Ok(())
844+
}
845+
805846
#[pymethod]
806847
fn set_default_verify_paths(&self, vm: &VirtualMachine) -> PyResult<()> {
807848
cfg_if::cfg_if! {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.