我无法加载密钥库。
"方法抛出' java.io.IOException'例外。 stream不代表pkcs12密钥库改造android"。
public static SSLSocketFactory getSSLSocketFactory() {
SSLContext sslContext = null;
try {
String password = ""; // .p12 is without a password.
// Load CAs from an InputStream
InputStream caInput = MainApplication.context.getResources()
.openRawResource(R.raw.generic_client_cert); // file present in Row directory with "generic_client_cert.p12" name.
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(caInput, password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("X509");
kmf.init(keyStore, password.toCharArray());
KeyManager[] keyManagers = kmf.getKeyManagers();
// creating an SSLSocketFactory that uses our TrustManager
sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagers, null, null);
} catch (IOException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (CertificateException e) {
e.printStackTrace();
} catch (KeyStoreException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (UnrecoverableKeyException e) {
e.printStackTrace();
}
return sslContext.getSocketFactory();
}
出了什么问题?任何帮助都会很棒(^ _ ^)
由于