Accessing Windows Certificate Store certs via Java?

前端 未结 4 1854
再見小時候
再見小時候 2020-12-09 18:46

I\'m looking to write something that can enumerate and use (to sign) certificates in CurrentUser/My and LocalMachine/My, but I haven\'t been able to find anything for the Wi

4条回答
  •  攒了一身酷
    2020-12-09 19:33

    KeyStore keyStore = KeyStore.getInstance(getKeyStoreType(), "SunMSCAPI");
    keyStore.load(null, null);
    
    try {
        Field field = keyStore.getClass().getDeclaredField("keyStoreSpi");
        field.setAccessible(true);
    
        KeyStoreSpi keyStoreVeritable = (KeyStoreSpi)field.get(keyStore);
        field = keyStoreVeritable.getClass().getEnclosingClass().getDeclaredField("entries");
        field.setAccessible(true);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, "Set accessible keyStoreSpi problem", e);
    }
    
    Enumeration enumeration = keyStore.aliases();
    

提交回复
热议问题