Fixing SSL Certificate Errors in Supervisely
In this tutorial you will learn how to fix errors with SSL certificate
Last updated
Was this helpful?
In this tutorial you will learn how to fix errors with SSL certificate
Last updated
Was this helpful?
SSL certificate errors can occur when you're working with the Supervisely SDK and the server uses a self-signed certificate.
In such cases, your code may not have the necessary certificate chain to validate the certificate provided by the server. This tutorial will guide you through the steps to resolve this issue by adding the certificate chain to the trusted store of your HTTP client.
Files for tutorial can be found in our GitHub repository .
Note: Disabling SSL checks is not recommended for security reasons, so it's best to add the certificate chain.
Requires Supervisely SDK
Create a .env
file in the same directory as your code and add the following line to it:
After creating a .env
file with SLY_EXTRA_CA_CERTS
variable, test your connection to the Supervisely server using the SDK. Supervisely SDK will automatically add your certificate to the bundle. If you've set the environment variables correctly, you will see this message in the terminal:
Note: Supervisely SDK uses HTTP client library requests
. If you are using a different HTTP client, please refer to its documentation for instructions on how to add a certificate chain.
If you already have a working certificate bundle on your machine, it is often found in /etc/ssl/certs/ca-certificates.crt
on Linux systems.
You can use this bundle directly or concatenate the certificate chain with it to create a new bundle.
If you need to create a new bundle, first obtain the certificate chain.
Concatenate the certificate chain and the ca-certificates file into a new bundle file using a text editor or command line tools. For example, you can use the cat
command on Linux:
To pass the certificate bundle to the Supervisely SDK (which uses the Requests library under the hood), set the REQUESTS_CA_BUNDLE
environment variable to the path of your new bundle.
After setting the environment variables, test your connection to the Supervisely server using the SDK. Your code should now be able to validate the server's self-signed certificate.
Note: if you're using urllib
, either directly or indirectly (pytorch
or some other library), don't forget to set SSL_CERT_FILE
environment variable.
In our example it's file.