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

[twitter][error] An unexpected error occurred: ValueError - Cannot set verify_mode to CERT_NONE when check_hostname is enabled.. #3614

Closed
jadedgnome opened this issue Feb 5, 2023 · 4 comments
Labels

Comments

@jadedgnome
Copy link

$ gallery-dl https://twitter.com/CatWorkers/media -d CatWorkers --verbose
[gallery-dl][debug] Version 1.25.0-dev
[gallery-dl][debug] Python 3.7.3 - Linux-3.13.0-170-generic-x86_64-with-debian-jessie-sid
[gallery-dl][debug] requests 2.28.1 - urllib3 1.26.14
[gallery-dl][debug] Configuration Files ['${HOME}/.gallery-dl.conf']
[gallery-dl][debug] Starting DownloadJob for 'https://twitter.com/CatWorkers/media'
[twitter][debug] Using TwitterMediaExtractor for 'https://twitter.com/CatWorkers/media'
[twitter][info] Requesting guest token
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.twitter.com:443
[twitter][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 .
[twitter][debug]
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/gallery_dl/job.py", line 91, in run
for msg in extractor:
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 73, in items
for tweet in self.tweets():
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 541, in tweets
return self.api.user_media(self.user)
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1070, in user_media
"userId": self._user_id_by_screen_name(screen_name),
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1179, in _user_id_by_screen_name
user = self.user_by_screen_name(screen_name)
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1171, in user_by_screen_name
return self._call(endpoint, params)["data"]["user"]["result"]
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1208, in _call
self._authenticate_guest()
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1197, in _authenticate_guest
guest_token = self._guest_token()
File "/usr/local/lib/python3.7/site-packages/gallery_dl/cache.py", line 115, in call
value = self.func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1194, in _guest_token
return str(self._call(endpoint, None, "POST", False)["guest_token"])
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/twitter.py", line 1212, in _call
headers=self.headers, fatal=None)
File "/usr/local/lib/python3.7/site-packages/gallery_dl/extractor/common.py", line 135, in request
response = session.request(method, url, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 499, in send
timeout=timeout,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 710, in urlopen
chunked=chunked,
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 401, in connect
context.verify_mode = resolve_cert_reqs(self.cert_reqs)
File "/usr/local/lib/python3.7/ssl.py", line 548, in verify_mode
super(SSLContext, SSLContext).verify_mode.set(self, value)
ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.

@jadedgnome
Copy link
Author

nitter.net works

gallery-dl https://nitter.net/CatWorkers/media -d CatWorkers --verbose
[gallery-dl][debug] Version 1.25.0-dev
[gallery-dl][debug] Python 3.7.3 - Linux-3.13.0-170-generic-x86_64-with-debian-jessie-sid
[gallery-dl][debug] requests 2.28.1 - urllib3 1.26.14
[gallery-dl][debug] Configuration Files ['${HOME}/.gallery-dl.conf']
[gallery-dl][debug] Starting DownloadJob for 'https://nitter.net/CatWorkers/media'
[nitter.net][debug] Using NitterMediaExtractor for 'https://nitter.net/CatWorkers/media'
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): nitter.net:443
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py:1052: InsecureRequestWarning: Unverified HTTPS request is being made to host 'nitter.net'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
InsecureRequestWarning,
[urllib3.connectionpool][debug] https://nitter.net:443 "GET /CatWorkers/media HTTP/1.1" 200 None
[urllib3.connectionpool][debug] https://nitter.net:443 "GET /pic/orig/media%2FFoJ2V5SX0AIkuvB.jpg HTTP/1.1" 200 541086
CatWorkers/nitter.net/CatWorkers/1621989079775678467_1.jpg
[urllib3.connectionpool][debug] https://nitter.net:443 "GET /pic/orig/media%2FFoHPPbBWAAAOGq_.jpg HTTP/1.1" 200 453363
CatWorkers/nitter.net/CatWorkers/1621805363065405440_1.jpg
[urllib3.connectionpool][debug] https://nitter.net:443 "GET /pic/orig/media%2FFoFPuw6WQAEb1e7.jpg HTTP/1.1" 200 385732
CatWorkers/nitter.net/CatWorkers/1621665011058753537_1.jpg
[urllib3.connectionpool][debug] https://nitter.net:443 "GET /pic/orig/media%2FFoC67eeakAEjHu6.jpg HTTP/1.1" 200 373330
CatWorkers/nitter.net/CatWorkers/1621501539964846081_1.jpg

@mikf
Copy link
Owner

mikf commented Feb 9, 2023

Might be related to the default TLS ciphers used for Twitter.

Try disabling the default "browser": "firefox" setting and see if that helps (-o browser=)

@cnotin
Copy link

cnotin commented Aug 15, 2023

Same error here :'( I've tried to dig but didn't find any solution yet

@inoyakaigor
Copy link

Same error here:

gallery-dl.exe -v --no-check-certificate https://x.com/ilo_ilong
[gallery-dl][debug] Version 1.26.8 - Executable
[gallery-dl][debug] Python 3.8.10 - Windows-10-10.0.22631
[gallery-dl][debug] requests 2.31.0 - urllib3 2.1.0
[gallery-dl][debug] Configuration Files ['%APPDATA%\\gallery-dl\\config.json']
[gallery-dl][debug] Starting DownloadJob for 'https://x.com/ilo_ilong'
[twitter][debug] Using TwitterUserExtractor for 'https://x.com/ilo_ilong'
[twitter][debug] Using TwitterTimelineExtractor for 'https://twitter.com/ilo_ilong/timeline'
[twitter][info] Requesting guest token
[urllib3.connectionpool][debug] Starting new HTTPS connection (1): api.twitter.com:443
[twitter][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 .
[twitter][debug]
Traceback (most recent call last):
  File "gallery_dl\job.pyc", line 127, in run
  File "gallery_dl\extractor\twitter.pyc", line 69, in items
  File "gallery_dl\extractor\twitter.pyc", line 483, in login
  File "gallery_dl\cache.pyc", line 115, in __call__
  File "gallery_dl\extractor\twitter.pyc", line 1688, in _login_impl
  File "gallery_dl\extractor\twitter.pyc", line 1253, in _authenticate_guest
  File "gallery_dl\cache.pyc", line 115, in __call__
  File "gallery_dl\extractor\twitter.pyc", line 1248, in _guest_token
  File "gallery_dl\extractor\twitter.pyc", line 1266, in _call
  File "gallery_dl\extractor\common.pyc", line 165, in request
  File "requests\sessions.pyc", line 589, in request
  File "requests\sessions.pyc", line 703, in send
  File "requests\adapters.pyc", line 486, in send
  File "urllib3\connectionpool.pyc", line 790, in urlopen
  File "urllib3\connectionpool.pyc", line 467, in _make_request
  File "urllib3\connectionpool.pyc", line 1096, in _validate_conn
  File "urllib3\connection.pyc", line 642, in connect
  File "urllib3\connection.pyc", line 744, in _ssl_wrap_socket_and_match_hostname
  File "ssl.pyc", line 720, in verify_mode
ValueError: Cannot set verify_mode to CERT_NONE when check_hostname is enabled.

@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

4 participants