r/cpp_questions • u/Stunning_Gas_3862 • 2d ago
OPEN Debugging certificate trust mismatches between Windows and OpenSSL in C++ apps
I maintain a C++ app on Windows that does TLS with OpenSSL, and I keep running into the same headache: the same server cert gets accepted by Windows (CryptoAPI/SChannel) but rejected by OpenSSL, or the other way around. Sometimes CryptoAPI builds a valid chain, sometimes OpenSSL can't find a trust anchor even though the cert is clearly in the Windows store. The result flips depending on the store, the CA bundle, and verification flags
For those who've dealt with this from C++
- How do you actually investigate the difference? Do you dump chains via CryptoAPI, run
openssl s_client/verify, write throwaway C++ that calls both APIs and compares, or some mix? - Is it usually quick to pin down the exact cause, or does it turn into hours of manual poking?
- Has anything existing actually made this straightforward for you, or is it still custom glue code?
I'm especially interested in how people maintaining C++ Windows apps handle this in practice what your debugging flow looks like when Windows and OpenSSL disagree on the same cert
1
u/hadrabap 1d ago
I deal a lot with TLS. Not directly with the codebase that uses OpenSSL, we do Java servers and clients. I deal with native languages at home. I use openssl s_client and curl debugging output. Good friend is openssl x509 -noout -text as well. By that you can see in the chains.
The worst part are browsers. They're not publishing much information. Best way is to go through Browser/CA specs and model the situations with custom CA (ROOT, intermediates, CRL server, OCSP responder if you need that...).
Sometimes, it is good to capture the traffic and visualize it in WireShark. But that's pretty rare, fortunately.
1
u/Wild_Meeting1428 1d ago
Could be very simple if you are lucky: as I know, openssl has its own trust store and does not use the windows store by default. So make sure to install every chain in both stores or find out how openssl can access the os store.
1
u/Discordbothost 1d ago
Before comparing trust stores, check that both clients get the same leaf cert. Run s_client with -servername set to the exact hostname your app uses and compare the leaf fingerprint. A different leaf points you toward SNI or the network path first.