From d7563bd50f01ef3c93a32c68a1c7007159301a14 Mon Sep 17 00:00:00 2001 From: TimeTREE98 Date: Sat, 17 Oct 2026 21:11:34 +0900 Subject: [PATCH 1/2] feat(tls): expose trust_anchors and grease_sigalgs_enabled --- python/wreq/tls.py | 10 ++++++++++ src/tls.rs | 13 +++++++++++++ tests/tls_test.py | 7 ++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/python/wreq/tls.py b/python/wreq/tls.py index c15901c1..b07d7144 100644 --- a/python/wreq/tls.py +++ b/python/wreq/tls.py @@ -420,6 +420,16 @@ class Params(TypedDict): Overrides the random AES hardware acceleration. """ + grease_sigalgs_enabled: NotRequired[bool] + """ + Whether the `signature_algorithms` extension includes a GREASE value. + """ + + trust_anchors: NotRequired[bytes] + """ + Encoded Trust Anchor IDs sent in a TLS 1.3 ClientHello. + """ + @final class TlsOptions: diff --git a/src/tls.rs b/src/tls.rs index 991d9a7b..21b90693 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -215,6 +215,12 @@ struct Builder { /// Overrides the random AES hardware acceleration. random_aes_hw_override: Option, + + /// Whether the `signature_algorithms` extension includes a GREASE value. + grease_sigalgs_enabled: Option, + + /// Encoded Trust Anchor IDs sent in a TLS 1.3 ClientHello. + trust_anchors: Option>, } /// TLS connection configuration options. @@ -382,6 +388,13 @@ impl TlsOptions { params.random_aes_hw_override, random_aes_hw_override ); + apply_option!( + set_if_some, + builder, + params.grease_sigalgs_enabled, + grease_sigalgs_enabled + ); + apply_option!(set_if_some, builder, params.trust_anchors, trust_anchors); } Self(builder.build()) diff --git a/tests/tls_test.py b/tests/tls_test.py index 2517deee..ab74b454 100644 --- a/tests/tls_test.py +++ b/tests/tls_test.py @@ -1,7 +1,7 @@ import pytest import wreq from wreq.emulation import Emulation -from wreq.tls import CertStore +from wreq.tls import CertStore, TlsOptions @pytest.mark.asyncio @@ -49,3 +49,8 @@ async def test_alps_new_endpoint(): async with resp: text = await resp.text() assert text is not None + + +def test_tls_options_trust_anchors_and_grease_sigalgs(): + opts = TlsOptions(grease_sigalgs_enabled=True, trust_anchors=b"") + assert opts is not None From 0a410d15b6ffb2810b9256d15b6542f10920c3f1 Mon Sep 17 00:00:00 2001 From: TimeTREE98 Date: Sun, 18 Oct 2026 11:09:18 +0900 Subject: [PATCH 2/2] feat(tls): expose TRUST_ANCHORS in ExtensionType --- python/wreq/tls.py | 1 + src/tls.rs | 1 + tests/tls_test.py | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/wreq/tls.py b/python/wreq/tls.py index b07d7144..b1662cad 100644 --- a/python/wreq/tls.py +++ b/python/wreq/tls.py @@ -124,6 +124,7 @@ class ExtensionType(Enum): NEXT_PROTO_NEG = auto() CHANNEL_ID = auto() RECORD_SIZE_LIMIT = auto() + TRUST_ANCHORS = auto() @final diff --git a/src/tls.rs b/src/tls.rs index 21b90693..32b01c81 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -110,6 +110,7 @@ define_enum!( NEXT_PROTO_NEG, CHANNEL_ID, RECORD_SIZE_LIMIT, + TRUST_ANCHORS, ); /// A builder for [`TlsOptions`]. diff --git a/tests/tls_test.py b/tests/tls_test.py index ab74b454..d7878b23 100644 --- a/tests/tls_test.py +++ b/tests/tls_test.py @@ -1,7 +1,7 @@ import pytest import wreq from wreq.emulation import Emulation -from wreq.tls import CertStore, TlsOptions +from wreq.tls import CertStore, ExtensionType, TlsOptions @pytest.mark.asyncio @@ -54,3 +54,8 @@ async def test_alps_new_endpoint(): def test_tls_options_trust_anchors_and_grease_sigalgs(): opts = TlsOptions(grease_sigalgs_enabled=True, trust_anchors=b"") assert opts is not None + + +def test_extension_type_trust_anchors(): + opts = TlsOptions(extension_permutation=[ExtensionType.TRUST_ANCHORS]) + assert opts is not None