0
我正面臨一個非常奇怪的錯誤。這個錯誤在今天開始發生,它在星期五工作,沒有任何變化,至少我沒有知道。從KeyStore獲取密鑰時出錯(java)
我有一個簡單的KeyStore,我存儲一個密鑰來加密一些數據。只是爲了測試創建一個單獨的應用程序來處理這個。這是代碼:
3210代碼是非常基本的,只是打開security.properties配置密鑰庫。現在的問題是我在下面一行中出現錯誤:
KeyStore.Entry entry = ks.getEntry(keyAlias, proParam);
我再說一次,這沒有發生,突然開始。文件沒問題,路徑沒問題,文件打開了,但是當我嘗試獲取KeyEntry時,我得到一個NumberFormatException,如果發生了什麼,我真的不知道。這是錯誤堆棧跟蹤:
Test at localhost:62013
Thread [main] (Suspended (exception NumberFormatException))
owns: InetAddress$Cache (id=58)
owns: Object (id=59)
Integer.parseInt(String, int) line: not available
Integer.<init>(String) line: not available
InetAddressCachePolicy.<clinit>() line: not available
InetAddress$Cache.getPolicy() line: not available
InetAddress$Cache.put(String, InetAddress[]) line: not available
InetAddress.cacheInitIfNeeded() line: not available
InetAddress.cacheAddresses(String, InetAddress[], boolean) line: not available
InetAddress.getAddressesFromNameService(String, InetAddress) line: not available
InetAddress.getLocalHost() line: not available
JarVerifier.getSystemEntropy() line: 783
JarVerifier.testSignatures(X509Certificate, CertificateFactory) line: 706
JarVerifier.access$400(X509Certificate, CertificateFactory) line: 34
JarVerifier$1.run() line: 183
JarVerifier$1.run() line: 149
AccessController.doPrivileged(PrivilegedExceptionAction<T>) line: not available [native method]
JarVerifier.<clinit>() line: 148
JceSecurity.loadPolicies(File, CryptoPermissions, CryptoPermissions) line: 316
JceSecurity.setupJurisdictionPolicies() line: 261
JceSecurity.access$000() line: 48
JceSecurity$1.run() line: 78
AccessController.doPrivileged(PrivilegedExceptionAction<T>) line: not available [native method]
JceSecurity.<clinit>() line: 76
JceSecurityManager.<clinit>() line: 65
CipherForKeyProtector(Cipher).<init>(CipherSpi, Provider, String) line: 252
CipherForKeyProtector.<init>(CipherSpi, Provider, String) line: 377
KeyProtector.unseal(SealedObject) line: 347
JceKeyStore.engineGetKey(String, char[]) line: 133
JceKeyStore(KeyStoreSpi).engineGetEntry(String, KeyStore$ProtectionParameter) line: not available
KeyStore.getEntry(String, KeyStore$ProtectionParameter) line: not available
Test.main(String[]) line: 39
請大家給我一個希望之光! 謝謝!
嘗試不在調試模式下運行它,或檢查是否沒有啓用異常斷點。正如你可以從openjdk的資源中看到的,InetAddressCachePolicy在內部拋出NumberFormatException,但是靜靜地捕獲它並繼續執行。出於某種原因,您的調試器決定在該點停止 –
謝謝康斯坦丁。您是對的,但KeyStore條目未加載,我需要該信息才能使應用程序正常工作。最後我認爲這是一個Eclipse問題。我將Eclipse安裝在一個新文件夾中,再次創建項目,並且一切正常。非常奇怪的錯誤:(。謝謝! – Robert