Try to search your question here, if you can't find : Ask Any Question Now ?

Null pointer exception in strongswan keystore

HomeCategory: stackoverflowNull pointer exception in strongswan keystore
Avatarsourav asked 3 months ago

I am trying to build strong swan app in Android. I am able to compile and build it but at runtime when I try to load LocalCertificateStore it returns null and as a result when adding certificate to keystore with store.setCertificateEntry(null, certificate); I get a null pointer exception.

java.lang.NullPointerException: Attempt to invoke virtual method ' android.content.Context.openFileOutput(java.lang.String, int)' on a null object reference

When I try to get certificates with TrustedCertificateManager.getInstance().getAllCACertificates()
it returns 0 certificates. But when I load AndroidCAStore (which is also loaded by TrustedCertificateManager) seperately it returns all the certificates.

The problem is keystore returns null. Earlier it would return

LocalCertificateStore Implementation not found.

But after adding Security.addProvider(new LocalCertificateKeyStoreProvider());
that error was gone.

KeyStore store = KeyStore.getInstance("LocalCertificateStore");
Hashtable<String, X509Certificate> hsh=TrustedCertificateManager.getInstance().getAllCACertificates();
Log.d("Loaded CA size",""+hsh.size()); //returns 0
store.setCertificateEntry(null, certificate);
1 Answers
Best Answer
AvatarArben answered 3 months ago
Your Answer

11 + 16 =

Popular Tags

WP Facebook Auto Publish Powered By :