0
我的應用程序需要只在所有讀取私鑰(以及相關的公共證書),沒有寫入密鑰庫,沒有密碼更改,沒有變化 - 只是閱讀。 是否有人知道肯定讀我可以使用此代碼:讀取和寫入Java密鑰庫
///doing some actions
KeyStore store = KeyStore.getInstance("foo", "bar");
store.load(iaminputstream, iampwd); // I'M JUST LOADING, I'M NOT GONNA STORE IT!
PrivateKey pk = (PrivateKey) store.getKey(iamalias, iamkeypass);
Certificate cert = store.getCertificate(iamalias);
///contnuing some actions
,而不是這樣的:
///doing some actions
KeyStore store = KeyStore.getInstance("foo", "bar");
try{
store.load(iaminputstream, iampwd); //I'VE LOADED
PrivateKey pk = (PrivateKey) store.getKey(iamalias, iamkeypass);
Certificate cert = store.getCertificate(iamalias);
} finally {
store.store(iamoutputstream, iampassword); //AND I'VE SAVED!
}
///contnuing some actions
證明鏈接的高度讚賞!
您是否確實運行了代碼並發現了任何問題? – Nishan 2012-07-30 07:24:52