Had some fun getting SSL to work with python requests & a mikrotik auto-generated let’s encrypt certificate.
The cert generation went fine, but initially trying to access in python3 requests would fail with
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)
even though it works in chrome w/o issue.
This is because mikrotik does not serve the full SSL chain, even if it is imported on router, and it seems linux often does not have the intermediate certs for LE loaded.
import requests
r = requests.get('https://mikrotik.example.com/rest/system/resource', auth=('user', 'pass'), verify="/path/to/certstore.pem")
Apparently browsers sometimes cache intermediate certificates? Or are smarter about fetching them? and normally webservers give out full chains? Would be nice if RouterOS would give full chain if one is available, since these certs are normally trusted. I can see the point of not giving the chain for an internal only-cert, but for a commonly trusted CA I was hoping to not need to carry special .pem files around with scripts anymore.
A device that does verification should have a full chain imported. Chrome has its own certificate manager, where it has all the ca and intermediate certificates.
It seems like it is not uncommon for a server to offer a full certificate chain to a client, and for most OS to only hold root certs. This is somewhat expected when using a commonly trusted root CA.
Apache used to have configuration SSLCertificateChainFile to load and serve intermediate certs, but now is integrated and loading of full chain happens by default. I think it is normal to expect a web server to offer full chain.
When tracing trust to a commonly accepted root cert, it is nice for the server to explain fully why it is trusted. My client only needs to hold a small number of root certs then. Intermediate certs might be short lived & not get updated on my IOT device. Let’s Encrypt has already deprecated 4 intermediate certs.
I don’t think that’s true. My RouterOS happily serves intermediate certificates, if they are present. The problem with LE client in RouterOS is that it doesn’t add any.