dcert 3.0.74__tar.gz → 3.0.76__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dcert-3.0.74 → dcert-3.0.76}/PKG-INFO +5 -1
- {dcert-3.0.74 → dcert-3.0.76}/README.md +4 -0
- {dcert-3.0.74 → dcert-3.0.76}/pyproject.toml +1 -1
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/__init__.py +9 -1
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/tools.py +144 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_tools.py +60 -1
- {dcert-3.0.74 → dcert-3.0.76}/.gitignore +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/auth.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/binary.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/checksums.json +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/cli.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/client.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/config.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/config.yaml +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/download.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/middleware.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/py.typed +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/resilience.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/src/dcert/server.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/__init__.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/conftest.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_auth.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_binary.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_cli.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_config.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_download.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_integration.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_middleware.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_resilience.py +0 -0
- {dcert-3.0.74 → dcert-3.0.76}/tests/test_server.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dcert
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.76
|
|
4
4
|
Summary: MCP server for TLS certificate analysis via the Model Context Protocol
|
|
5
5
|
Project-URL: Homepage, https://github.com/SCGIS-Wales/dcert
|
|
6
6
|
Project-URL: Repository, https://github.com/SCGIS-Wales/dcert
|
|
@@ -121,7 +121,11 @@ Leaving out `session` uses a shared default session that is created on first use
|
|
|
121
121
|
| `convert_pem_to_pfx()` | Convert PEM cert and key to PKCS12/PFX |
|
|
122
122
|
| `create_keystore()` | Create a PKCS12 keystore (Java compatible) |
|
|
123
123
|
| `create_truststore()` | Create a PKCS12 truststore from CA certs |
|
|
124
|
+
| `tls_scan()` | Enumerate the TLS versions, cipher suites and groups a server accepts |
|
|
124
125
|
| `list_cipher_suites()` | List TLS cipher suites from the IANA registry (offline) |
|
|
126
|
+
| `list_tls_policies()` | List the catalogued TLS security policies (offline) |
|
|
127
|
+
| `show_tls_policy()` | Show one catalogued TLS security policy (offline) |
|
|
128
|
+
| `tls_policy_test()` | Test an endpoint against a TLS security policy, or identify the closest one |
|
|
125
129
|
| `explain_cipher_suite()` | Explain one cipher suite in any notation (offline) |
|
|
126
130
|
|
|
127
131
|
The network facing functions accept the shared mTLS and connection options (`client_cert`, `client_key`, `pkcs12`, `cert_password`, `ca_cert`, `connect_to`, `resolve`, `proxy`, `noproxy`) as keyword arguments.
|
|
@@ -79,7 +79,11 @@ Leaving out `session` uses a shared default session that is created on first use
|
|
|
79
79
|
| `convert_pem_to_pfx()` | Convert PEM cert and key to PKCS12/PFX |
|
|
80
80
|
| `create_keystore()` | Create a PKCS12 keystore (Java compatible) |
|
|
81
81
|
| `create_truststore()` | Create a PKCS12 truststore from CA certs |
|
|
82
|
+
| `tls_scan()` | Enumerate the TLS versions, cipher suites and groups a server accepts |
|
|
82
83
|
| `list_cipher_suites()` | List TLS cipher suites from the IANA registry (offline) |
|
|
84
|
+
| `list_tls_policies()` | List the catalogued TLS security policies (offline) |
|
|
85
|
+
| `show_tls_policy()` | Show one catalogued TLS security policy (offline) |
|
|
86
|
+
| `tls_policy_test()` | Test an endpoint against a TLS security policy, or identify the closest one |
|
|
83
87
|
| `explain_cipher_suite()` | Explain one cipher suite in any notation (offline) |
|
|
84
88
|
|
|
85
89
|
The network facing functions accept the shared mTLS and connection options (`client_cert`, `client_key`, `pkcs12`, `cert_password`, `ca_cert`, `connect_to`, `resolve`, `proxy`, `noproxy`) as keyword arguments.
|
|
@@ -23,7 +23,7 @@ Usage with the typed async wrappers::
|
|
|
23
23
|
result = await analyze_certificate(target="example.com", session=session)
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
__version__ = "3.0.
|
|
26
|
+
__version__ = "3.0.76"
|
|
27
27
|
|
|
28
28
|
from dcert.client import create_client
|
|
29
29
|
from dcert.config import Config, load_config
|
|
@@ -64,7 +64,11 @@ from dcert.tools import (
|
|
|
64
64
|
explain_cipher_suite,
|
|
65
65
|
export_pem,
|
|
66
66
|
list_cipher_suites,
|
|
67
|
+
list_tls_policies,
|
|
68
|
+
show_tls_policy,
|
|
67
69
|
tls_connection_info,
|
|
70
|
+
tls_policy_test,
|
|
71
|
+
tls_scan,
|
|
68
72
|
verify_key_match,
|
|
69
73
|
)
|
|
70
74
|
|
|
@@ -115,4 +119,8 @@ __all__ = [
|
|
|
115
119
|
"create_truststore",
|
|
116
120
|
"list_cipher_suites",
|
|
117
121
|
"explain_cipher_suite",
|
|
122
|
+
"tls_scan",
|
|
123
|
+
"list_tls_policies",
|
|
124
|
+
"show_tls_policy",
|
|
125
|
+
"tls_policy_test",
|
|
118
126
|
]
|
|
@@ -727,6 +727,146 @@ async def create_truststore(
|
|
|
727
727
|
return await call_tool("create_truststore", arguments, session=session, timeout=timeout)
|
|
728
728
|
|
|
729
729
|
|
|
730
|
+
async def tls_scan(
|
|
731
|
+
*,
|
|
732
|
+
target: str,
|
|
733
|
+
allow_legacy_tls: bool = False,
|
|
734
|
+
max_handshakes: int | None = None,
|
|
735
|
+
sni: str | None = None,
|
|
736
|
+
starttls: str | None = None,
|
|
737
|
+
connect_to: str | list[str] | None = None,
|
|
738
|
+
resolve: str | list[str] | None = None,
|
|
739
|
+
proxy: str | None = None,
|
|
740
|
+
noproxy: str | None = None,
|
|
741
|
+
session: Session | None = None,
|
|
742
|
+
timeout: float | None = None,
|
|
743
|
+
) -> ToolResponse:
|
|
744
|
+
"""Enumerate the TLS versions, cipher suites and groups *target* accepts.
|
|
745
|
+
|
|
746
|
+
Args:
|
|
747
|
+
target: HTTPS URL or hostname (``host[:port]`` with *starttls*).
|
|
748
|
+
allow_legacy_tls: Also test TLS 1.0 and 1.1.
|
|
749
|
+
max_handshakes: Most handshakes the scan may make (server default 120).
|
|
750
|
+
sni: Override the SNI hostname.
|
|
751
|
+
starttls: ``"smtp"``, ``"imap"``, ``"pop3"`` or ``"ftp"``.
|
|
752
|
+
connect_to: Redirect the connection while keeping the target hostname.
|
|
753
|
+
resolve: Pin ``HOST:PORT:ADDRESS`` like curl's ``--resolve``.
|
|
754
|
+
proxy: Forward proxy URL; ``""`` forces a direct connection.
|
|
755
|
+
noproxy: Comma separated hosts bypassing the proxy.
|
|
756
|
+
session: Session to use; the shared default when ``None``.
|
|
757
|
+
timeout: Per call timeout in seconds.
|
|
758
|
+
"""
|
|
759
|
+
arguments = build_arguments(
|
|
760
|
+
"tls_scan",
|
|
761
|
+
{"target": target},
|
|
762
|
+
{
|
|
763
|
+
"max_handshakes": max_handshakes,
|
|
764
|
+
"sni": sni,
|
|
765
|
+
"starttls": starttls,
|
|
766
|
+
"connect_to": connect_to,
|
|
767
|
+
"resolve": resolve,
|
|
768
|
+
"proxy": proxy,
|
|
769
|
+
"noproxy": noproxy,
|
|
770
|
+
},
|
|
771
|
+
defaulted={"allow_legacy_tls": (allow_legacy_tls, False)},
|
|
772
|
+
)
|
|
773
|
+
return await call_tool("tls_scan", arguments, session=session, timeout=timeout)
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
async def list_tls_policies(
|
|
777
|
+
*,
|
|
778
|
+
provider: str | None = None,
|
|
779
|
+
session: Session | None = None,
|
|
780
|
+
timeout: float | None = None,
|
|
781
|
+
) -> ToolResponse:
|
|
782
|
+
"""List the catalogued TLS security policies (no network access).
|
|
783
|
+
|
|
784
|
+
Args:
|
|
785
|
+
provider: ``"aws_alb"``, ``"aws_nlb"``, ``"aws_cloudfront"``,
|
|
786
|
+
``"aws_api_gateway"`` or ``"mozilla"``.
|
|
787
|
+
session: Session to use; the shared default when ``None``.
|
|
788
|
+
timeout: Per call timeout in seconds.
|
|
789
|
+
"""
|
|
790
|
+
arguments = build_arguments("list_tls_policies", {}, {"provider": provider})
|
|
791
|
+
return await call_tool("list_tls_policies", arguments, session=session, timeout=timeout)
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
async def show_tls_policy(
|
|
795
|
+
*,
|
|
796
|
+
policy_id: str,
|
|
797
|
+
provider: str | None = None,
|
|
798
|
+
session: Session | None = None,
|
|
799
|
+
timeout: float | None = None,
|
|
800
|
+
) -> ToolResponse:
|
|
801
|
+
"""Show one catalogued TLS security policy (no network access).
|
|
802
|
+
|
|
803
|
+
Args:
|
|
804
|
+
policy_id: Policy id, e.g. ``"ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09"``.
|
|
805
|
+
provider: The provider, when several publish the same id.
|
|
806
|
+
session: Session to use; the shared default when ``None``.
|
|
807
|
+
timeout: Per call timeout in seconds.
|
|
808
|
+
"""
|
|
809
|
+
arguments = build_arguments("show_tls_policy", {"id": policy_id}, {"provider": provider})
|
|
810
|
+
return await call_tool("show_tls_policy", arguments, session=session, timeout=timeout)
|
|
811
|
+
|
|
812
|
+
|
|
813
|
+
async def tls_policy_test(
|
|
814
|
+
*,
|
|
815
|
+
target: str,
|
|
816
|
+
policy: str | None = None,
|
|
817
|
+
provider: str | None = None,
|
|
818
|
+
versions: Sequence[str] | None = None,
|
|
819
|
+
identify: bool = False,
|
|
820
|
+
strict: bool = False,
|
|
821
|
+
allow_legacy_tls: bool = False,
|
|
822
|
+
sni: str | None = None,
|
|
823
|
+
starttls: str | None = None,
|
|
824
|
+
session: Session | None = None,
|
|
825
|
+
timeout: float | None = None,
|
|
826
|
+
**options: Unpack[ConnectionOptions],
|
|
827
|
+
) -> ToolResponse:
|
|
828
|
+
"""Test whether *target* behaves exactly like a named TLS security policy.
|
|
829
|
+
|
|
830
|
+
Args:
|
|
831
|
+
target: HTTPS URL or hostname (``host[:port]`` with *starttls*).
|
|
832
|
+
policy: Policy id, e.g. ``"ELBSecurityPolicy-TLS13-1-2-Res-PQ-2025-09"``;
|
|
833
|
+
required unless *identify* is set.
|
|
834
|
+
provider: The provider, when several publish the policy id.
|
|
835
|
+
versions: Only these protocol versions, e.g. ``["1.2", "1.3"]``.
|
|
836
|
+
identify: Rank every catalogued policy instead of testing one.
|
|
837
|
+
strict: Report an inconclusive verdict as a failure (exit code 10).
|
|
838
|
+
allow_legacy_tls: Also test TLS 1.0 and 1.1.
|
|
839
|
+
sni: Override the SNI hostname.
|
|
840
|
+
starttls: ``"smtp"``, ``"imap"``, ``"pop3"`` or ``"ftp"``.
|
|
841
|
+
session: Session to use; the shared default when ``None``.
|
|
842
|
+
timeout: Per call timeout in seconds.
|
|
843
|
+
**options: See :class:`ConnectionOptions`.
|
|
844
|
+
|
|
845
|
+
Raises:
|
|
846
|
+
ValueError: If neither or both of *policy* and *identify* are given.
|
|
847
|
+
"""
|
|
848
|
+
if (policy is None) != identify:
|
|
849
|
+
raise ValueError("tls_policy_test() needs exactly one of policy or identify=True")
|
|
850
|
+
arguments = build_arguments(
|
|
851
|
+
"tls_policy_test",
|
|
852
|
+
{"target": target},
|
|
853
|
+
{
|
|
854
|
+
"policy": policy,
|
|
855
|
+
"provider": provider,
|
|
856
|
+
"versions": list(versions) if versions else None,
|
|
857
|
+
"sni": sni,
|
|
858
|
+
"starttls": starttls,
|
|
859
|
+
**options,
|
|
860
|
+
},
|
|
861
|
+
defaulted={
|
|
862
|
+
"identify": (identify, False),
|
|
863
|
+
"strict": (strict, False),
|
|
864
|
+
"allow_legacy_tls": (allow_legacy_tls, False),
|
|
865
|
+
},
|
|
866
|
+
)
|
|
867
|
+
return await call_tool("tls_policy_test", arguments, session=session, timeout=timeout)
|
|
868
|
+
|
|
869
|
+
|
|
730
870
|
async def list_cipher_suites(
|
|
731
871
|
*,
|
|
732
872
|
protocol: str | None = None,
|
|
@@ -783,4 +923,8 @@ TOOL_FUNCTIONS: tuple[Callable[..., Awaitable[ToolResponse]], ...] = (
|
|
|
783
923
|
create_truststore,
|
|
784
924
|
list_cipher_suites,
|
|
785
925
|
explain_cipher_suite,
|
|
926
|
+
tls_scan,
|
|
927
|
+
list_tls_policies,
|
|
928
|
+
show_tls_policy,
|
|
929
|
+
tls_policy_test,
|
|
786
930
|
)
|
|
@@ -40,7 +40,11 @@ from dcert.tools import (
|
|
|
40
40
|
export_pem,
|
|
41
41
|
extract_text,
|
|
42
42
|
list_cipher_suites,
|
|
43
|
+
list_tls_policies,
|
|
44
|
+
show_tls_policy,
|
|
43
45
|
tls_connection_info,
|
|
46
|
+
tls_policy_test,
|
|
47
|
+
tls_scan,
|
|
44
48
|
verify_key_match,
|
|
45
49
|
)
|
|
46
50
|
|
|
@@ -306,6 +310,55 @@ CASES = [
|
|
|
306
310
|
{"protocol": "1.3", "offerable": True},
|
|
307
311
|
),
|
|
308
312
|
(explain_cipher_suite, {"suite": "C02F"}, "explain_cipher_suite", {"suite": "C02F"}),
|
|
313
|
+
(tls_scan, {"target": "e"}, "tls_scan", {"target": "e"}),
|
|
314
|
+
(list_tls_policies, {}, "list_tls_policies", {}),
|
|
315
|
+
(
|
|
316
|
+
tls_policy_test,
|
|
317
|
+
{
|
|
318
|
+
"target": "e",
|
|
319
|
+
"policy": "P",
|
|
320
|
+
"versions": ("1.2", "1.3"),
|
|
321
|
+
"strict": True,
|
|
322
|
+
"resolve": "e:443:10.0.0.1",
|
|
323
|
+
},
|
|
324
|
+
"tls_policy_test",
|
|
325
|
+
{
|
|
326
|
+
"target": "e",
|
|
327
|
+
"policy": "P",
|
|
328
|
+
"versions": ["1.2", "1.3"],
|
|
329
|
+
"strict": True,
|
|
330
|
+
"resolve": "e:443:10.0.0.1",
|
|
331
|
+
},
|
|
332
|
+
),
|
|
333
|
+
(
|
|
334
|
+
tls_policy_test,
|
|
335
|
+
{"target": "e", "identify": True},
|
|
336
|
+
"tls_policy_test",
|
|
337
|
+
{"target": "e", "identify": True},
|
|
338
|
+
),
|
|
339
|
+
(list_tls_policies, {"provider": "aws_alb"}, "list_tls_policies", {"provider": "aws_alb"}),
|
|
340
|
+
(
|
|
341
|
+
show_tls_policy,
|
|
342
|
+
{"policy_id": "P", "provider": "aws_nlb"},
|
|
343
|
+
"show_tls_policy",
|
|
344
|
+
{"id": "P", "provider": "aws_nlb"},
|
|
345
|
+
),
|
|
346
|
+
(
|
|
347
|
+
tls_scan,
|
|
348
|
+
{
|
|
349
|
+
"target": "e",
|
|
350
|
+
"allow_legacy_tls": True,
|
|
351
|
+
"max_handshakes": 50,
|
|
352
|
+
"resolve": ["e:443:10.0.0.1"],
|
|
353
|
+
},
|
|
354
|
+
"tls_scan",
|
|
355
|
+
{
|
|
356
|
+
"target": "e",
|
|
357
|
+
"allow_legacy_tls": True,
|
|
358
|
+
"max_handshakes": 50,
|
|
359
|
+
"resolve": ["e:443:10.0.0.1"],
|
|
360
|
+
},
|
|
361
|
+
),
|
|
309
362
|
]
|
|
310
363
|
|
|
311
364
|
|
|
@@ -385,7 +438,7 @@ async def test_input_validation(open_session):
|
|
|
385
438
|
|
|
386
439
|
|
|
387
440
|
def test_all_tool_functions_present():
|
|
388
|
-
assert len(TOOL_FUNCTIONS) ==
|
|
441
|
+
assert len(TOOL_FUNCTIONS) == 17
|
|
389
442
|
# inspect, not asyncio: asyncio.iscoroutinefunction is deprecated from 3.14.
|
|
390
443
|
assert all(inspect.iscoroutinefunction(f) for f in TOOL_FUNCTIONS)
|
|
391
444
|
|
|
@@ -763,3 +816,9 @@ def test_default_session_is_rebuilt_for_a_new_event_loop(monkeypatch, caplog):
|
|
|
763
816
|
assert len(created) == 2
|
|
764
817
|
assert "Dropping the default session of a previous event loop" in caplog.text
|
|
765
818
|
asyncio.run(close_default_session())
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
@pytest.mark.parametrize("kwargs", [{}, {"policy": "P", "identify": True}])
|
|
822
|
+
async def test_tls_policy_test_needs_exactly_one_of_policy_or_identify(kwargs):
|
|
823
|
+
with pytest.raises(ValueError, match="exactly one"):
|
|
824
|
+
await tls_policy_test(target="e", **kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|