diff options
| author | Claude <noreply@anthropic.com> | 2026-10-21 23:26:47 +0000 |
|---|---|---|
| committer | Claude <noreply@anthropic.com> | 2026-10-21 23:26:47 +0000 |
| commit | eecb3b3f6f737af959734f71b230d3f671601717 (patch) | |
| tree | 12c221c9aff6bd60bad1a76b5c1ee080d3b45b6c /plugins | |
| parent | 1e25068c2793a1c50c91c2941055ce5043c4a7fe (diff) | |
security-guidance: name the test certificates in the config file so the fixture works with LibreSSLmhegazy/sg-unreadable-store-cert
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/security-guidance/tests/test_tls_store_unreadable_cert.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/plugins/security-guidance/tests/test_tls_store_unreadable_cert.py b/plugins/security-guidance/tests/test_tls_store_unreadable_cert.py index 52744a9b..c76aa8aa 100644 --- a/plugins/security-guidance/tests/test_tls_store_unreadable_cert.py +++ b/plugins/security-guidance/tests/test_tls_store_unreadable_cert.py @@ -120,23 +120,25 @@ def pki(tmp_path_factory): "subjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid\n") (d / "leaf.cnf").write_text("subjectAltName=DNS:localhost,IP:127.0.0.1\n" + leaf) (d / "other-host.cnf").write_text("subjectAltName=DNS:other.invalid\n" + leaf) - (d / "ca.cnf").write_text( - "[req]\ndistinguished_name=dn\nx509_extensions=v3\nprompt=no\n" - "[dn]\nCN=placeholder\n" - "[v3]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=critical,keyCertSign,cRLSign\n" - "subjectKeyIdentifier=hash\n") + # The subject goes in the config file: LibreSSL ignores -subj when the config has prompt=no. + def req_config(common_name): + (d / "req.cnf").write_text( + "[req]\ndistinguished_name=dn\nx509_extensions=v3\nprompt=no\n" + f"[dn]\nCN={common_name}\n" + "[v3]\nbasicConstraints=critical,CA:TRUE\nkeyUsage=critical,keyCertSign,cRLSign\n" + "subjectKeyIdentifier=hash\n") out = {} # server certificate -> (the CA that signs it, its extensions) servers = {"trusted": ("trusted", "leaf.cnf"), "untrusted": ("untrusted", "leaf.cnf"), "other-host": ("trusted", "other-host.cnf")} for ca in ("trusted", "untrusted"): - _openssl("req", "-x509", "-newkey", "rsa:2048", "-nodes", "-config", "ca.cnf", - "-keyout", f"{ca}-ca.key", "-out", f"{ca}-ca.pem", "-days", "2", - "-subj", f"/CN=sg test {ca} CA", cwd=d) + req_config(f"sg test {ca} CA") + _openssl("req", "-x509", "-newkey", "rsa:2048", "-nodes", "-config", "req.cnf", + "-keyout", f"{ca}-ca.key", "-out", f"{ca}-ca.pem", "-days", "2", cwd=d) + req_config("sg test server") for name, (ca, extensions) in servers.items(): - _openssl("req", "-newkey", "rsa:2048", "-nodes", "-config", "ca.cnf", - "-keyout", f"{name}.key", "-out", f"{name}.csr", - "-subj", "/CN=sg test server", cwd=d) + _openssl("req", "-newkey", "rsa:2048", "-nodes", "-config", "req.cnf", + "-keyout", f"{name}.key", "-out", f"{name}.csr", cwd=d) _openssl("x509", "-req", "-in", f"{name}.csr", "-CA", f"{ca}-ca.pem", "-CAkey", f"{ca}-ca.key", "-CAcreateserial", "-out", f"{name}.pem", "-days", "2", "-extfile", extensions, cwd=d) |
