如何将.cer转换为BKS

时间:2014-01-22 13:37:46

标签: android https

我有一个扩展名为.cer的证书。我的应用程序将通过https连接到站点。 我正在尝试使用此命令创建BKS

keytool -import -alias tomcat -file X://KeyStore/fidoserver.crt -keypass password - keystore X://KeyStore/keystore.bks -storetype BKS -storepass 222222 -providerClass org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath X://KeyStore/bcprov-jdk16-146.jar

,但获取FileNotFound X://KeyStore/keystore.bks异常 如果我有.cer,如何获得BKS?

1 个答案:

答案 0 :(得分:17)

尝试在终端上使用它(我假设您已经在http://bouncycastle.org/latest_releases.html下载了Bouncy Castle jar):

keytool -importcert -v -trustcacerts -file "path_to_cert/interm_ca.cer" -alias IntermediateCA -keystore "path_to_your_app/res/raw/myKeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "path_to_bouncycastle/bcprov-jdk16-145.jar" -storetype BKS -storepass mysecret

它应该在你的应用程序的/ res / raw文件夹上创建一个BKS密钥库。然后,使用以下命令验证密钥库:

keytool -list -keystore "path_to_your_app/res/raw/myKeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "path_to_bouncycastle/bcprov-jdk16-145.jar" -storetype BKS -storepass mysecret

它应该输出这样的东西: RootCA, 22.10.2010, trustedCertEntry, Thumbprint (MD5): 24:77:D9:A8:91:D1:3B:FA:88:2D:C2:FF:F8:CD:33:93 IntermediateCA, 22.10.2010, trustedCertEntry, Thumbprint (MD5): 98:0F:C3:F8:39:F7:D8:05:07:02:0D:E3:14:5B:29:43

Source