Skip to content

Commit

Permalink
🎨 submodule name to _rustls
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed Sep 21, 2023
1 parent dcf45d5 commit 01efbf0
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">Wassima 🔒</h1>

<p style="text-align: center">
<p align="center">
<small>I named this library after my wife, whom I trust the most. ❤️</small>
</p>

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classifiers = [

[tool.maturin]
features = ["pyo3/extension-module"]
module-name = "wassima._rustls"

[tool.pytest.ini_options]
log_level = "DEBUG"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn root_der_certificates(py: Python) -> PyResult<Vec<&PyBytes>> {
}

#[pymodule]
fn wassima(_py: Python, m: &PyModule) -> PyResult<()> {
fn _rustls(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(root_der_certificates, m)?)?;
Ok(())
}
45 changes: 29 additions & 16 deletions tests/test_ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,37 @@


@pytest.mark.parametrize(
"host, port, expect_failure, failure_label",
"host, port, expect_failure",
[
("1.1.1.1", 443, False, None),
("google.com", 443, False, None),
("self-signed.badssl.com", 443, True, "self-signed certificate"),
("untrusted-root.badssl.com", 443, True, "self-signed certificate"),
("tls-v1-2.badssl.com", 1012, False, None),
("1.1.1.1", 443, False),
("google.com", 443, False),
(
"self-signed.badssl.com",
443,
True,
),
(
"untrusted-root.badssl.com",
443,
True,
),
(
"tls-v1-2.badssl.com",
1012,
False,
),
(
"sha1-intermediate.badssl.com",
443,
True,
"unable to get local issuer certificate",
),
("one.one.one.one", 443, False, None),
("edellroot.badssl.com", 443, True, "unable to get local issuer certificate"),
("developer.mozilla.org", 443, False, None),
("letsencrypt.org", 443, False, None),
("one.one.one.one", 443, False),
("edellroot.badssl.com", 443, True),
("developer.mozilla.org", 443, False),
("letsencrypt.org", 443, False),
],
)
def test_ctx_use_system_store(
host: str, port: int, expect_failure: bool, failure_label: str
) -> None:
def test_ctx_use_system_store(host: str, port: int, expect_failure: bool) -> None:
ctx = create_default_ssl_context()

s = socket(AF_INET, SOCK_STREAM)
Expand All @@ -39,8 +48,12 @@ def test_ctx_use_system_store(
if expect_failure:
with pytest.raises(SSLError) as exc:
s.connect((host, port))

assert failure_label in exc.value.args[1]
ssl_err = exc.value.args[1]
assert (
"self-signed" in ssl_err
or "self signed" in ssl_err
or "unable to get local issuer certificate" in ssl_err
)
else:
s.connect((host, port))
assert s.getpeercert() is not None
Expand Down
2 changes: 1 addition & 1 deletion wassima/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from functools import lru_cache
from ssl import DER_cert_to_PEM_cert

from .wassima import root_der_certificates
from ._rustls import root_der_certificates


@lru_cache()
Expand Down
File renamed without changes.

0 comments on commit 01efbf0

Please sign in to comment.