Yes. Python verifies SSL certificates when connecting to secure HTTPS services. If the server cannot validate the certificate chain, the request may fail even though the API works in a browser.
Here are some things to investigate:
- Check system time: An incorrect server date or time can cause certificate validation failures.
- Update CA certificates: Your VPS may have an outdated certificate authority bundle.
- Check Python certificate configuration: Libraries such as
requests may use a different CA bundle from your operating system.
- Update dependencies: Check whether your Python environment uses an outdated
certifi package.
- Inspect the certificate chain: Verify that the external API provides a valid and complete certificate chain.
- Test from the server: Use
curl to compare the server's certificate validation with Python's behavior.
Never solve this problem by permanently setting verify=False. That disables certificate verification and makes your application vulnerable to certain man-in-the-middle attacks.