diff --git a/python/wreq/tls.py b/python/wreq/tls.py index c15901c1..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 @@ -420,6 +421,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..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`]. @@ -215,6 +216,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 +389,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..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 +from wreq.tls import CertStore, ExtensionType, TlsOptions @pytest.mark.asyncio @@ -49,3 +49,13 @@ 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 + + +def test_extension_type_trust_anchors(): + opts = TlsOptions(extension_permutation=[ExtensionType.TRUST_ANCHORS]) + assert opts is not None