curl_cffi icon indicating copy to clipboard operation
curl_cffi copied to clipboard

TLS Version not changing

Open Nixh5 opened this issue 10 months ago • 6 comments

I'm trying to get 771 at the ja3 fingerprint but its not working, the curl_cffi asks me for an integer and I've tried what it allows me but the 772 never changes to 771 so I assume the TLS version is not changing no matter what I do, or something else...

from curl_cffi import CurlOpt, requests

response = requests.get("https://tools.scrapfly.io/api/fp/ja3",
    curl_options={
        CurlOpt.SSLVERSION: 6, #tried also, 0, 1 ...
})
print(response.text)

I've looked to use CURL_SSLVERSION_MAX_TLSv1_2 as well but I dont find any way to do that with curl_cffi.

Versions curl_cffi 0.6.3b1 Kubuntu 12 Python 3.11.6

Nixh5 avatar Mar 31 '24 00:03 Nixh5

ok I'll close this, I would say its a bug of scrapfly or something because here I get 771: https://check.ja3.zone/

Nixh5 avatar Mar 31 '24 01:03 Nixh5

ok at https://check.ja3.zone/ I get 771 but the TLS version is still 1.3, when what I want is 1.2, for example using this code it uses 1.2 how can I do this with curl_cffi?:


import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.poolmanager import PoolManager
import ssl
from urllib3.util.ssl_ import create_urllib3_context


class ForceTLS12Adapter(HTTPAdapter):

    def init_poolmanager(self, *args, **kwargs):
        context = create_urllib3_context(ssl_version=ssl.PROTOCOL_TLSv1_2)
        self.poolmanager = PoolManager(*args, ssl_context=context, **kwargs)


s = requests.Session()
s.mount('https://', ForceTLS12Adapter())

response = s.get('https://check.ja3.zone/')

print(response.text)

Nixh5 avatar Mar 31 '24 01:03 Nixh5

Sorry, this won't work, as curl_cffi does not use urllib3 under the hood. The reason is probably that TLS version is fixed in upstream curl-impersonate. Anyway, TLS 1.3 is preferred to TLS 1.2.

perkfly avatar Apr 01 '24 03:04 perkfly

Sorry, this won't work, as curl_cffi does not use urllib3 under the hood. The reason is probably that TLS version is fixed in upstream curl-impersonate. Anyway, TLS 1.3 is preferred to TLS 1.2.

Hi, here https://github.com/yifeikong/curl_cffi/issues/30 you suggested that putting in CURL_SSLVERSION_MAX_TLSv1_2 will work. Getting mixed signals, is changing TLS versions not supported by this library?

Alexei17 avatar Apr 03 '24 22:04 Alexei17

I would like it to be supported because I'm trying to achieve an specific ja3 fingerprint so not being allowed to change the TLS version is breaking my ja3.

Nixh5 avatar Apr 03 '24 22:04 Nixh5

Hi, here #30 you suggested that putting in CURL_SSLVERSION_MAX_TLSv1_2 will work. Getting mixed signals, is changing TLS versions not supported by this library?

This SHOULD work theoretically, but I havn't tried that in practice. If it does not work, it's probably because TLS version is fixed by the patch.

I'm trying to achieve an specific ja3 fingerprint

You can follow the updates of the pinned issue, customized fingerprints support is tracked there.

perkfly avatar Apr 04 '24 01:04 perkfly

Just rechecked this issue, there are two TLS versions: the request one and the negotiated one:

"tls_version_record": "771",
"tls_version_negotiated": "772",

See: https://tls.peet.ws/api/all, which is more clear.

perkfly avatar Jun 26 '24 07:06 perkfly

It seems that the TLS version is indeed fixed to 771, which is TLS v1.2. Luckily, most modern apps use the same version. However, if you are trying to impersonate a very old app, then it won't work, now.

perkfly avatar Jun 26 '24 08:06 perkfly