Understanding "certificate verify failed" Error in Python
When attempting to retrieve data from a HTTPS website using Python, it's possible to encounter the following error:
certificate verify failed: unable to get local issuer certificate
This error occurs because Python cannot verify the security certificate of the website. By default, Python relies on its own set of trusted root certificates to verify website certificates. However, if the website's certificate is not signed by one of these trusted root certificates, Python will fail the verification process.
Solution: Installing System Certificates
One solution to this error is to install the website's security certificate into the system's trusted root certificate store. On a Mac, this can be achieved by running the following command in Terminal:
/Applications/Python\ 3.7/Install\ Certificates.command
This command will install the system's default set of trusted root certificates into Python's trusted certificate store.
Understanding the Role of Certificates
SSL certificates are used to establish a secure connection between a web browser and a web server. They contain information about the website's identity and are used to encrypt data transmitted between the two parties.
Additional Resources for Learning
To improve your understanding of SSL certificates and security, consider the following resources:
The above is the detailed content of Why Does Python Throw a \'certificate verify failed\' Error When Accessing HTTPS Websites?. For more information, please follow other related articles on the PHP Chinese website!