Showing posts with label ca. Show all posts
Showing posts with label ca. Show all posts

11 August 2020

Using custom CA in python virtual environment

 You have installed your custom CA in your client machine. Using curl, everthing is fine(refer here).

But since your python script  use  virtenv, your script cannot see the custom CA.



This is because python virtualenv looking the certifcates in different place than the normal python 

$ python -c "import requests; print ( requests.certs.where() )"
/etc/ssl/certs/ca-certificates.crt

$ (.venv) python -c "import requests; print (requests.certs.where())" 
.../.venv/lib/python3.6/site-packages/certifi-2020.6.20-py3.6.egg/certifi/cacert.pem


Solution, is to import the custom CA to the virtual Environtment.

openssl x509 -in $specific_ca.crt -text >> $virtualenv/lib/python3.6/site-packages/certifi-2020.6.20-py3.6.egg/certifi/cacert.pem



ref:

https://stackoverflow.com/questions/34931378/certificate-verification-when-using-virtual-environments

06 August 2020

Add custom CA to ubuntu

tested with ubuntu 18:04


1) sudo apt-get install ca-certificates



2) copy CA certificate to local:
      sudo cp CERTIFICATE.crt /usr/local/share/ca-certificates/


If your certificate in PEM format, need to convert to .crt using this command:
openssl x509 -outform der -in CERTIFICATE.pem -out CERTIFICATE.crt

3) update certificate
  sudo update-ca-certificates



ref: