Wrote a small program, a simple test HTTPBasicAuthorization based REST API, the results of the program on the Windows machine error:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
Error reporting on Linux machines:
"bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],)"
The small procedure is as follows:
#!/bin/python
import requests
from requests.auth import HTTPBasicAuth
from pprint import pprint
my_url = 'https://192.168.12.34/nodes'
def main():
try:
r = requests.get(my_url,
auth=HTTPBasicAuth('username', 'passw0rd'))
pprint(r.status_code)
pprint(r.json())
except Exception as ex:
print("Exception: {ex}".format(ex=ex))
if __name__ == '__main__':
main()
The solution, it turns out, is to add verify=False to the parameters of the GET function
The root cause is that the certificate given by the site under test is considered questionable, so verify=False is required to pass the error.
, however, is not enough, because with verify=False, a large section of warning is printed out for each connection, indicating that the connection is secure. How can you disable this message if it is secured?Add a sentence to: requests. Packages. Urllib3. Disable_warnings ()
final code is as follows:
#!/bin/python
import requests
from requests.auth import HTTPBasicAuth
from pprint import pprint
my_url = 'https://192.168.12.34/nodes'
def main():
try:
requests.packages.urllib3.disable_warnings()
r = requests.get(my_url,
auth=HTTPBasicAuth('username', 'passw0rd'),
verify=False)
pprint(r.status_code)
pprint(r.json())
except Exception as ex:
print("Exception: {ex}".format(ex=ex))
if __name__ == '__main__':
main()
div>
Read More:
- Python uses requests to request and reports SSL: CERTIFICATE_VERIFY_FAILED error
- python:urllib2.URLError urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
- Spark login error unable to verify certificate and certificate host name verification failed
- Idea svn connection https error report: E230001: Server SSL certificate verification failed: certificate issued
- ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
- [SSL: CERTIFICATE_VERIFY_FAILED] Certificate Verify Failed (_ssl.C:579)
- How to Fix SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed.
- URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
- [Solved] Error: unable to verify the first certificate
- Git prompt error setting certificate verify locations
- When we crawl to the HTTPS website, the SSL certificate error is solved
- Configure HTTPS and self signed certificate for nginx
- K8s configure HTTPS with existing certificate
- wget Error: ERROR: cannot verify nih.at’s certificate, issued by “/C=US/O=Let‘s Encrypt/CN=R3”
- SAP ABAP HTTPS installation certificate to SAP application server
- Python – SSL certificate error
- cURL error 60: SSL certificate problem: self signed certificate in certificate chain
- svn: E230001: Server SSL certificate verification failed: certificate issued
- Python module learning-Paramiko-Use python to throw an exception: Authentication failed.
- (20210301 solved) can’t connect to HTTPS URL because the SSL module is not available