Я успешно разместил серверную часть на HTTPs и использую PostMan, но возникла проблема с интеграцией https в приложении Android.
Я получаю исключение и выдаю вверх.
java.io.IOException: исключение развертывания закрытого ключа - java.security.NoSuchAlgorithmException: 1.2.840.113549.1.5.12 SecretKeyFactory недоступна
Код Android:
Код: Выделить всё
public static SSLSocketFactory getSocketFactory(Context ctx) {
try {
// Get an instance of the Bouncy Castle KeyStore format
KeyStore keyStore = KeyStore.getInstance("PKCS12");
System.out.println(" KeyStore Load successfully ========");
// Get the raw resource, which contains the keystore with
// your trusted certificates (root and any intermediate certs)
String securityKey = ctx.getResources().getString(R.string.securitykey);
System.out.println("===========s Secrete Key " + securityKey);
InputStream in = ctx.getResources().openRawResource(R.raw.baeldung);
System.out.println(" File Read Load successfully ========" );
System.out.println(" File Read Load successfully ========" + in.available());
if(in==null){
System.out.println(" This is empty file");
}
try {
// Initialize the keystore with the provided trusted certificates
// Provide the password of the keystore
System.out.println("== keystore is Start load =======");
keyStore.load(in, securityKey.toCharArray());
System.out.println("== keystore is compplete load =======");
}catch(Exception e) {
e.printStackTrace();
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(keyStore);
sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
return sf;
} catch (Exception e) {
e.printStackTrace();
throw new AssertionError(e);
}
}
Журналы ошибок:
Код: Выделить всё
KeyStore Load successfully ========
I/System.out: ===========s Secrete Key Saktiman@121995
I/System.out: File Read Load successfully ========
I/System.out: File Read Load successfully ========2748
I/System.out: == keystore is Start load =======
W/System.err: java.io.IOException: exception unwrapping private key - java.security.NoSuchAlgorithmException: 1.2.840.113549.1.5.12 SecretKeyFactory not available
W/System.err: at com.android.org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.unwrapKey(PKCS12KeyStoreSpi.java:652)
W/System.err: at com.android.org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(PKCS12KeyStoreSpi.java:891)
W/System.err: at java.security.KeyStore.load(KeyStore.java:1544)
Подробнее здесь: https://stackoverflow.com/questions/765 ... ecurity-no