1、生成服務器端私鑰kserver.keystore文件
keytool -genkey -alias serverkey -validity 1 -keystore kserver.keystore
2、根據私鑰,導出服務器端安全證書
keytool -export -alias serverkey -keystore kserver.keystore -file server.crt
3、將服務器端證書,導入到客戶端的Trust KeyStore中
keytool -import -alias serverkey -file server.crt -keystore tclient.keystore
4、生成客戶端私鑰kclient.keystore文件
keytool -genkey -alias clientkey -validity 1 -keystore kclient.keystore
5、根據私鑰,導出客戶端安全證書
keytool -export -alias clientkey -keystore kclient.keystore -file client.crt
6、將客戶端證書,導入到服務器端的Trust KeyStore中
keytool -import -alias clientkey -file client.crt -keystore tserver.keystore
生成的文件分成兩組,服務器端保存:kserver.keystore tserver.keystore 客戶端保存:kclient.keystore tclient.kyestore。
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -genkey -alias clientkey -validity 1 -keystore kclient.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
keytool -import -alias clientkey -file android.crt -keystore kclient.bks -storetype BKS
keytool -import -alias csswebkey -file ca.crt -keystore kclient.bks -storetype BKS
keytool -import -alias cakey -file ca.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore tclient.bks -storetype BKS
keytool -import -alias serverkey -file server.crt -keystore client.bks -storetype BKS -provider org.bouncycastle.jce.provider.BouncyCastleProvider
I had the same issue and here are the steps to properly create a custom keystore that can be used for debugging in eclipse:
Basically what you should do is that change both storepasswd and keypasswd for the alias androiddebugkey to "android".
here are the commands:
keytool -changealias -keystore mykeystore.keystore -alias myalias -destalias androiddebugkey
keytool -keypasswd -keystore mykeystore.keystore -alias androiddebugkey
keytool -storepasswd -keystore mykeystore.keystore
ant 自動打包apk
key.alias= 別名
此別名壹開始以為可以隨便寫,後來多次嘗試發現亂寫打包壹定不成功,此別名要與第壹次生成簽名時的別名壹至,由於簽名不是我申請的,申請簽名的同事也忘記了簽名的別名,如此只好找工具看壹下簽名的信息了,其實工具不用找了,在jdk中有
直接keytool -list -v -keystore xxxx.keystore -storepass 密碼簽名的信息就有了
keytool -list -v -keystore keystoreName -storepass keystorePassword