以编程方式从信任库中删除证书

Delete Certificate from Truststore programmatical

我尝试从 JAVA 中的 Truststore 编程删除证书。

public static void deleteCertificate(final File trustStore, final String password, final String alias) {
    try (final FileInputStream fis = new FileInputStream(trustStore)) {
        final KeyStore keystore = KeyStore.getInstance("UBER");
        keystore.load(fis, password.toCharArray());
        if (keystore.containsAlias(alias)) {
            keystore.deleteEntry(alias);
        }
        else {
            throw new IllegalStateException("Alias " + alias + " not found in trust store");
        }
    }
    catch (final Exception e) {
        throw new IllegalStateException("Error occures while deleting certificate.", e);

程序通过行 keystore.deleteEntry(别名),但证书仍在信任库中。没有错误发生,应用程序运行没有任何问题。

我做错了什么?

提前致谢。 :-)

尝试存储结果

 OutputStream writeStream = new FileOutputStream(filePathToStore);
 keystore.store(writeStream, password);
 writeStream.close();