- Code: Select all
python -c 'import requests; req=requests.get("https://www.apple.com/"); print req.status_code'
Seems pretty straightforward, right? No, not really.
- Code: Select all
jkeenan@Kraken ~ % python -c 'import requests; req=requests.get("https://www.apple.com/"); print req.status_code'
From cffi callback <function _verify_callback at 0x104d30c80>:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/SSL.py", line 309, in wrapper
_lib.X509_up_ref(x509)
AttributeError: 'module' object has no attribute 'X509_up_ref'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Python/2.7/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/Library/Python/2.7/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Python/2.7/site-packages/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/Library/Python/2.7/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)
On Mojave, no problem:
- Code: Select all
home:~ miniserver$ python -c 'import requests; req=requests.get("https://www.apple.com/"); print req.status_code'
200
On Catalina, with Python3. Note the syntax change for the print statement.
- Code: Select all
jkeenan@Kraken ~ % python3 -c 'import requests; req=requests.get("https://www.apple.com/"); print(req.status_code)'
200
This has bitten me on three different plugins this weekend. The workaround, for now, is to disable certificate checking:
- Code: Select all
jkeenan@Kraken ~ % python -c 'import requests; req=requests.get("https://www.apple.com/", verify=False); print req.status_code'
/Library/Python/2.7/site-packages/requests/packages/urllib3/connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html
InsecureRequestWarning)
200
Warning messages, but at least it runs.