2015-10-08 41 views
2

若要加载Windows中的证书我用:如何在Linux中以编程方式列出所有SSL/TLS证书?

KeyStore keystore = KeyStore.getInstance("WINDOWS-ROOT"); //and WINDOWS-MY 
keystore.load(null, null); 
// here operations to make the list 

在安卓

KeyStore keystore = KeyStore.getInstance("AndroidCAStore"); 
keystore.load(null, null); 
// here operations to make the list 

我如何能做到这一点的Linux呢?如果使用这个API在Linux下无法完成,我怎么能以另一种方式来完成?

回答

0

您可以/etc/ssl/certs下找到它们。只需做一个ls -l告诉你更多。

ls -l /etc/ssl/certs/ 

他们都在.pem.crt。易于使用java.io.File对象阅读。你需要一个循环来读取它们。

0

您是否尝试用函数替换keystore的确切类型以获取默认值?

例如为:

KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); 
keystore.load(null, null); 
+0

是的,它不起作用。它会打开空的“jks”(java keystore)密钥库。无论如何感谢您的尝试! – VanDir

相关问题