0

Ran the following commands.

PS C:\Users\anups\Desktop\Cloud_AntiScalant> mkcert -install
Created a new local CA 
The local CA is now installed in the system trust store! ⚡️

PS C:\Users\anups\Desktop\Cloud_AntiScalant> mkcert localhost

Created a new certificate valid for the following names 
 - "localhost"

The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅

It will expire on 5 October 2024 

Started the uvicorn server with the following command.

cls;uvicorn main:app --reload --host 127.0.0.1 --port=8000 --ssl-certfile="C:\Users\anups\Desktop\Cloud_AntiScalant\localhost.pem" --ssl-keyfile="C:\Users\anups\Desktop\Cloud_AntiScalant\localhost-key.pem"

I am able to open browser with https://127.0.0.1:8000 but it still shows that its unsecure and says certificate status says OK.

I am running the client app with the following code:

url = 'https://127.0.0.1:8000/'
r = requests.get(url)

I get the following error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='127.0.0.1', port=8000): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

I checked the certmgr.msc and I see the mkcert installed.

Any someone please help me?

Anup Buchke
  • 5,210
  • 5
  • 22
  • 38
  • Python does not use Windows certificate store so you can add what you want it will not affect Python. What certs are used by Python depends on the used package. Some for example use the certificates from `certifi` package. In the end you have to manually configure the used https client and add your self-signed certificate as trusted. – Robert Jul 06 '22 at 08:40

0 Answers0