Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patreon] "ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled." #5576

Closed
tkzv opened this issue May 10, 2024 · 0 comments
Labels

Comments

@tkzv
Copy link

tkzv commented May 10, 2024

I try to connect to Patreon (without logging in) through an untrusted proxy, disable certificate checking and end up with this error:

$ gallery-dl --proxy socks5h://184.181.217.194:4145 http://patreon.com/noben --write-pages --download-archive noben.sqlite --no-check-certificate --verbose
[gallery-dl][debug] Version 1.27.0-dev
[gallery-dl][debug] Python 3.11.9 - Linux-5.15.32-gentoo-r1-x86_64-AMD_FX-tm-8300_Eight-Core_Processor-with-glibc2.38
[gallery-dl][debug] requests 2.31.0 - urllib3 2.2.1
[gallery-dl][debug] Configuration Files ['${HOME}/.config/gallery-dl/config.json']
[gallery-dl][debug] Starting DownloadJob for 'http://patreon.com/noben'
[patreon][debug] Using PatreonCreatorExtractor for 'http://patreon.com/noben'
[patreon][debug] TLS 1.2 disabled.
[patreon][warning] no 'session_id' cookie set
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): www.patreon.com:443
[patreon][error] An unexpected error occurred: ValueError - Cannot set verify_mode to CERT_NONE when check_hostname is enabled.. Please run gallery-dl again with the --verbose flag, copy its output and report this issue on https://github.com/mikf/gallery-dl/issues .
[patreon][debug] 
Traceback (most recent call last):
  File "/home/tkzv/.local/lib/python3.11/site-packages/gallery_dl/job.py", line 127, in run
    for msg in extractor:
  File "/home/tkzv/.local/lib/python3.11/site-packages/gallery_dl/extractor/patreon.py", line 38, in items
    for post in self.posts():
                ^^^^^^^^^^^^
  File "/home/tkzv/.local/lib/python3.11/site-packages/gallery_dl/extractor/patreon.py", line 311, in posts
    campaign_id = self._get_campaign_id(query)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tkzv/.local/lib/python3.11/site-packages/gallery_dl/extractor/patreon.py", line 337, in _get_campaign_id
    page = self.request(url, notfound="creator").text
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tkzv/.local/lib/python3.11/site-packages/gallery_dl/extractor/common.py", line 168, in request
    response = session.request(method, url, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1099, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 653, in connect
    sock_and_verified = _ssl_wrap_socket_and_match_hostname(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/urllib3/connection.py", line 768, in _ssl_wrap_socket_and_match_hostname
    context.verify_mode = resolve_cert_reqs(cert_reqs)
    ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ssl.py", line 742, in verify_mode
    super(SSLContext, SSLContext).verify_mode.__set__(self, value)
ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.

This looks similar to #4891, but my urllib is newer.

@mikf mikf added the bug label May 10, 2024
mikf added a commit that referenced this issue May 10, 2024
e.g. when 'browser' is set to a non-empty value and gallery-dl creates
its own SSLContext instance instead of using requests' and urllib3's
defaults.

urllib3 disables this option for its default contexts,
since it does this check on its own.

Fixes "ValueError: Cannot set verify_mode to CERT_NONE when
check_hostname is enabled" when using --no-check-certificate.

(#3614, #4891, #5576)
@mikf mikf closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants