Skip to content

Commit 58c6f88

Browse files
committed
[TLS/Windows] Skip disallowed certs in the trusted CA list.
Turns out the list of trusted root certificates contains disallowed certificates (i.e. certificates which are no longer trusted or have been revoked). We need to check for the property `CERT_DISALLOWED_FILETIME_PROP_ID` to check if and when the certificates should be distrusted.
1 parent 964a535 commit 58c6f88

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

platform/windows/os_windows.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1680,10 +1680,20 @@ String OS_Windows::get_system_ca_certificates() {
16801680
HCERTSTORE cert_store = CertOpenSystemStoreA(0, "ROOT");
16811681
ERR_FAIL_COND_V_MSG(!cert_store, "", "Failed to read the root certificate store.");
16821682

1683+
FILETIME curr_time;
1684+
GetSystemTimeAsFileTime(&curr_time);
1685+
16831686
String certs;
16841687
PCCERT_CONTEXT curr = CertEnumCertificatesInStore(cert_store, nullptr);
16851688
while (curr) {
1686-
DWORD size = 0;
1689+
FILETIME ft;
1690+
DWORD size = sizeof(ft);
1691+
// Check if the certificate is disallowed.
1692+
if (CertGetCertificateContextProperty(curr, CERT_DISALLOWED_FILETIME_PROP_ID, &ft, &size) && CompareFileTime(&curr_time, &ft) != -1) {
1693+
curr = CertEnumCertificatesInStore(cert_store, curr);
1694+
continue;
1695+
}
1696+
// Encode and add to certificate list.
16871697
bool success = CryptBinaryToStringA(curr->pbCertEncoded, curr->cbCertEncoded, CRYPT_STRING_BASE64HEADER | CRYPT_STRING_NOCR, nullptr, &size);
16881698
ERR_CONTINUE(!success);
16891699
PackedByteArray pba;

0 commit comments

Comments
 (0)