I am using Python and OpenSSL to connect to a site using TLS (in some cross-platform software, so it would be too much work to switch to CryptoAPI for everything); I don't want to distribute (and update) a custom list of certificates, though. I want to get them from the platform. On OS X and Linux this is fairly straightforward, but Windows ships with an incomplete list of trusted root certificate authorities for TLS; basically just Microsoft's own certificates, then dynamically adds trust roots to the store when high-level TLS stuff (such as loading a web page in Internet Explorer over HTTPS) has to verify a trust root it hasn't previously seen. (This process is explained here.) This means I can enumerate the Windows root certificate store with wincertstore
, but it's useless because on machines with more recently-installed OSes, that store will be almost empty.
Microsoft provides detailed instructions for administrators to pre-retrieve this list so as to be able to operate machines with tightly-controlled network access; however, I cannot find any reference to an API that will do the same thing, and just download all trusted root certificates from Microsoft. (Honestly, in the age of weekly multi-megabyte system updates, I don't see why pre-downloading these is such a big deal, if it's just a cache; for bonus points please explain why this needs to happen at all.)
So: is there an API that would allow me to tell the system to just pre-cache the trusted root certificates according to whatever rules it uses? Failing that, if it's really impossible (i.e. if CryptoAPI can only download one trust root at a time and only if you feed it a certificate signed by that root), is there a way to hook up OpenSSL certificate verification to CryptoAPI's trust store so that the verification will download and cache trust roots just like a native TLS connection would?