Skip to content

Fix openssl error reasons #5739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Lib/test/test_httplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,8 +1695,6 @@ def test_attributes(self):
h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
self.assertEqual(h.timeout, 30)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_networked(self):
# Default settings: requires a valid cert from a trusted CA
import ssl
Expand Down Expand Up @@ -1769,8 +1767,6 @@ def test_networked_good_cert(self):
h.close()
self.assertIn('nginx', server_string)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_networked_bad_cert(self):
# We feed a "CA" cert that is unrelated to the server's cert
import ssl
Expand Down
8 changes: 6 additions & 2 deletions stdlib/src/ssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,8 +1183,12 @@ mod _ssl {
let file = file
.rsplit_once(&['/', '\\'][..])
.map_or(file, |(_, basename)| basename);
// TODO: map the error codes to code names, e.g. "CERTIFICATE_VERIFY_FAILED", just requires a big hashmap/dict
let errstr = e.reason().unwrap_or("unknown error");
// TODO: finish map
let default_errstr = e.reason().unwrap_or("unknown error");
let errstr = match default_errstr {
"certificate verify failed" => "CERTIFICATE_VERIFY_FAILED",
_ => default_errstr,
};
let msg = if let Some(lib) = e.library() {
// add `library` attribute
let attr_name = vm.ctx.as_ref().intern_str("library");
Expand Down
Loading