You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but I have an exception org.spongycastle.jcajce.provider.asymmetric.util.ExtendedInvalidKeySpecException
org.spongycastle.jcajce.provider.asymmetric.util.ExtendedInvalidKeySpecException: unable to process key spec: java.io.IOException: algorithm identifier 1.2.840.10045.2.1 in key not recognised at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePrivate(KeyFactorySpi.java:105) at java.security.KeyFactory.generatePrivate(KeyFactory.java:186) at org.XXXXXX.loadPrivateKey(CertProvider.java:45) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) Caused by: java.io.IOException: algorithm identifier 1.2.840.10045.2.1 in key not recognised at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.generatePrivate(KeyFactorySpi.java:153) at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePrivate(KeyFactorySpi.java:91) ... 17 more
any indication to solve this? or may SC on android can handle *.pkcs8, so I don't need to convert to pkcs12 (at least for this momment I just need *.pkcs8 files).
THX.
The text was updated successfully, but these errors were encountered:
Hi,
need to convert pkcs8 to pkcs12 so I used this code to load privatekey from pkcs8 file :
public static PrivateKey loadPrivateKey(String keyFile) { try { File f = new File(keyFile); FileInputStream fis = null; fis = new FileInputStream(f); DataInputStream dis = new DataInputStream(fis); byte[] keyBytes = new byte[(int) f.length()]; dis.readFully(keyBytes); dis.close(); PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(keyBytes); KeyFactory kf = KeyFactory.getInstance("RSA"); PrivateKey pk = kf.generatePrivate(spec); return pk; } catch (FileNotFoundException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (InvalidKeySpecException e) { e.printStackTrace(); } return null; }
but I have an exception org.spongycastle.jcajce.provider.asymmetric.util.ExtendedInvalidKeySpecException
org.spongycastle.jcajce.provider.asymmetric.util.ExtendedInvalidKeySpecException: unable to process key spec: java.io.IOException: algorithm identifier 1.2.840.10045.2.1 in key not recognised at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePrivate(KeyFactorySpi.java:105) at java.security.KeyFactory.generatePrivate(KeyFactory.java:186) at org.XXXXXX.loadPrivateKey(CertProvider.java:45) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.access$600(ActivityThread.java:141) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5041) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) at dalvik.system.NativeStart.main(Native Method) Caused by: java.io.IOException: algorithm identifier 1.2.840.10045.2.1 in key not recognised at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.generatePrivate(KeyFactorySpi.java:153) at org.spongycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePrivate(KeyFactorySpi.java:91) ... 17 more
any indication to solve this? or may SC on android can handle *.pkcs8, so I don't need to convert to pkcs12 (at least for this momment I just need *.pkcs8 files).
THX.
The text was updated successfully, but these errors were encountered: