Created
January 3, 2017 06:38
-
-
Save babafeng/a294b286c16fa7354625fb3b605bf32f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// keystore pass | |
String store_password = "storepass"; | |
// alias | |
String alias = "feng"; | |
// key pass | |
String private_password = "keypass"; | |
// 创建针对jks文件的输入流 | |
InputStream inputStream = new FileInputStream("C:\Users\Vii26\Desktop\feng_pub.keystore"); | |
// 创建KeyStore实例 | |
KeyStore keyStore = KeyStore.getInstance("JKS"); | |
keyStore.load(inputStream, store_password.toCharArray()); | |
// 获取私钥 | |
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias,private_password.toCharArray()); | |
// 获得公钥 | |
PublicKey publicKey= keyStore.getCertificate(alias).getPublicKey(); | |
System.out.println(privateKey); | |
System.out.println(publicKey); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment