urllib3 unable to get local issuer certificate
时间: 2023-10-28 09:00:09 浏览: 45
The error "urllib3 unable to get local issuer certificate" indicates that the SSL certificate of the server you are trying to connect to cannot be verified by urllib3. This error typically occurs when urllib3 cannot find the necessary root certificate authority (CA) certificates on your system to validate the SSL certificate.
To resolve this issue, you can try the following steps:
1. Update the CA certificates: Make sure that your system's CA certificates are up to date. You can do this by updating the ca-certificates package on your system.
2. Set the path to CA certificates explicitly: You can set the `REQUESTS_CA_BUNDLE` environment variable to the path of the CA bundle file (e.g., cacert.pem) that contains trusted CA certificates. This can be done before making the HTTP request using urllib3.
```python
import os
os.environ['REQUESTS_CA_BUNDLE'] = '/path/to/cacert.pem'
```
Replace `/path/to/cacert.pem` with the actual path to the CA bundle file on your system.
3. Disable SSL verification (not recommended): If you trust the server you are connecting to and want to bypass SSL verification, you can disable it entirely. However, this is not recommended for security reasons.
To disable SSL verification, you can pass `verify=False` parameter when making the HTTP request using urllib3:
```python
import urllib3
http = urllib3.PoolManager(cert_reqs='CERT_NONE')
response = http.request('GET', 'https://example.com', verify=False)
```
Again, keep in mind that disabling SSL verification should only be done if you fully trust the server you are connecting to.
By trying these steps, you should be able to resolve the "urllib3 unable to get local issuer certificate" error.