Class Crypt32ExtUtil

java.lang.Object
org.jetbrains.nativecerts.win32.Crypt32ExtUtil

public class Crypt32ExtUtil extends Object
Get custom (enterprise/user-installed) trusted root certificates from Windows certificate stores via CryptoAPI.

Native handles and structures are opaque MemorySegments; see Crypt32Ext for the bindings and WinCryptStructures for the structure layouts.
  • Constructor Details

    • Crypt32ExtUtil

      public Crypt32ExtUtil()
  • Method Details

    • getCustomTrustedRootCertificates

      public static Collection<X509Certificate> getCustomTrustedRootCertificates()
      Certificates from the "ROOT" stores of all customTrustedCertificatesLocations plus those intermediate ("CA" store) certificates that Windows itself can validate up to a trusted root.
    • gatherEnterpriseCertsForLocation

      public static List<X509Certificate> gatherEnterpriseCertsForLocation(int location, String storeName)
      Enumerates all certificates of one physical system store.
      Parameters:
      location - One of CERT_SYSTEM_STORE_* constants
      storeName - Logical store name, e.g. "ROOT" or "CA"
      Returns:
      Parsed certificates; an empty list if the store does not exist
    • validateCertificate

      public static void validateCertificate(byte[] encodedCertificate)
      Asks Windows to build a certificate chain for the given certificate (offline, using cached revocation data only) and to verify it against the SSL policy.
      Throws:
      WindowsCertificateException - if the chain cannot be built or does not satisfy the policy, e.g. with Crypt32Ext.CERT_E_UNTRUSTEDROOT when the root is not trusted