bogdanfinn / tls-client

net/http.Client like HTTP Client with options to select specific client TLS Fingerprints to use for requests.
BSD 4-Clause "Original" or "Old" License
667 stars 133 forks source link

[Bug]: failed to do request: Post "https://xx": tls: unknown ClientHelloID: Custom-1 #100

Closed AlexPaiva closed 4 months ago

AlexPaiva commented 4 months ago

TLS client version

Latest

System information

Linux

Issue description

Sending a custom client I get failed to do request: Post "https://site": tls: unknown ClientHelloID: Custom-1 even if I send the custom values perfectly. What is wrong?

Steps to reproduce / Code Sample

I am using https://github.com/rawandahmad698/noble-tls/ which is a python implementation but basically

cS = noble_tls.Session(
                    ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",#session_config["ja3_string"],
                    h2_settings=session_config["h2_settings"],
                    h2_settings_order=session_config["h2_settings_order"],
                    supported_signature_algorithms=session_config["supported_signature_algorithms"],
                    supported_versions=session_config["supported_versions"],
                    key_share_curves=session_config["key_share_curves"],
                    cert_compression_algo=session_config["cert_compression_algo"],
                    pseudo_header_order=session_config["pseudo_header_order"],
                    connection_flow=session_config["connection_flow"],
                    header_order=session_config["header_order"]
                )
bogdanfinn commented 4 months ago

@AlexPaiva as far as i can understand this, this is not a bug in the code but you are configuring your custom tls client wrong.

Please check the docs of the mentioned project / repository how it is done in there. I can't give you support for NobleTLS

AlexPaiva commented 4 months ago

@AlexPaiva as far as i can understand this, this is not a bug in the code but you are configuring your custom tls client wrong.

Please check the docs of the mentioned project / repository how it is done in there. I can't give you support for NobleTLS

Thanks, Noble is just a python wrapper to call your tls client basically.

Running the code directly from the library documentation:

import noble_tls

async def main():
    await noble_tls.update_if_necessary() # Update TLS client libs from bogdanfinn/tls-client

    session = noble_tls.Session(
        ja3_string="771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0",
        h2_settings={
            "HEADER_TABLE_SIZE": 65536,
            "MAX_CONCURRENT_STREAMS": 1000,
            "INITIAL_WINDOW_SIZE": 6291456,
            "MAX_HEADER_LIST_SIZE": 262144
        },
        h2_settings_order=[
            "HEADER_TABLE_SIZE",
            "MAX_CONCURRENT_STREAMS",
            "INITIAL_WINDOW_SIZE",
            "MAX_HEADER_LIST_SIZE"
        ],
        supported_signature_algorithms=[
            "ECDSAWithP256AndSHA256",
            "PSSWithSHA256",
            "PKCS1WithSHA256",
            "ECDSAWithP384AndSHA384",
            "PSSWithSHA384",
            "PKCS1WithSHA384",
            "PSSWithSHA512",
            "PKCS1WithSHA512",
        ],
        supported_versions=["GREASE", "1.3", "1.2"],
        key_share_curves=["GREASE", "X25519"],
        cert_compression_algo="brotli",
        pseudo_header_order=[
            ":method",
            ":authority",
            ":scheme",
            ":path"
        ],
        connection_flow=15663105,
        header_order=[
            "accept",
            "user-agent",
            "accept-encoding",
            "accept-language"
        ]
    )

    res = await session.post(
        "https://www.example.com/",
        headers={
            "key1": "value1",
        },
        proxy="http://user:password@host:port"
    )
    print(res.text)

Doesn't work, gives failed to decode error.

bogdanfinn commented 4 months ago

@AlexPaiva if the example in the nobletls repo does not work i guess the perfect place to report that would be the nobleTLS issues: https://github.com/rawandahmad698/noble-tls/issues

AlexPaiva commented 4 months ago

Yeah, hope the guy can help me out. Thanks anyhow!