Hello @Izaf ,
Thank you for sharing such a detailed analysis along with the crlproof and wproxy samples. Based on those, the behavior here appears to relate to the revocation check on the proxy certificate, rather than to CA trust, name, or date.
When reproducing this with a local secure proxy whose leaf certificate is trusted and valid but whose only CRL distribution point is unreachable, the observed results were 0x00000000 without revocation, 0x01000040 with revocation, and 12188 from WinHttpSendRequest. When the same certificate carries no CDP at all, revocation comes back as status unknown only and the request proceeds, so it appears to be the combination of a present CDP and an unreachable CRL that turns the result into a failure.
On this point, Windows provides a related option, WINHTTP_OPTION_IGNORE_CERT_REVOCATION_OFFLINE (Windows 10 2004 and later, set on the request handle), described in the WinHTTP option flags as allowing a secure connection to use a certificate whose CRL could not be downloaded. The SECURITY_FLAG_IGNORE_* set does not include a flag for revocation, so this option is the corresponding mechanism for the "revocation could not be performed" case.
One thing worth noting from the observations is that the per-request relaxations, including SECURITY_FLAG_IGNORE_*, the secure-failure callback, and WINHTTP_OPTION_IGNORE_CERT_REVOCATION_OFFLINE, appear to apply to the origin server certificate rather than to the secure proxy certificate. When the ignore-offline option was set for the proxy leg, the call returned success but the request still stopped at 12188. This is consistent with --insecure and the callback having no effect on the proxy leg, and it suggests there may not be a per-request option to relax revocation for the proxy certificate specifically.
For mitigation, it may help to adjust things on the environment side: allowing the CRL host to be fetched directly (for Let's Encrypt, that is c.lencr.org) by adding it to the proxy bypass list or otherwise permitting direct outbound HTTP to it, so that CryptoAPI can retrieve the proxy certificate's CRL without going through the proxy. Other options to consider include pre-seeding that CRL into the machine cache, using a proxy certificate whose CRL is reachable without the proxy, or adjusting the revocation policy for that path at the Schannel level. Trying the ignore-offline option on your side may also be worth a look, though in this reproduction it did not change the outcome for the proxy case.
Hope these information help. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.