KeyStore in Android

903 views Asked by At

I am trying to install the certificate using keystore in my app. However I am getting an exception:

Throwable occurred: java.security.cert.CertificateException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: java.lang.RuntimeException: error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long

Tried a few things (ex: getInstance("X.509", "BC");) to get rid off this error but it didn't work. Not quite sure, how to get rid of this.

I am new to development and have a fair idea how keystore works. Any help will be appreciated. Thanks in advance.

try{

                    String configString = config.getString("imcwingw-latest.cert");
                    String decodedCert = BASE64Decoder.decode(configString);
                    InputStream bis = new ByteArrayInputStream(decodedCert.getBytes()); 
                    KeyStore ks = KeyStore.getInstance("BKS");
                    ks.load(null, null);
                    String alias = "myalias";

                    CertificateFactory cf = CertificateFactory.getInstance( "X.509");
                    Certificate cert = cf.generateCertificate(bis);
                    ks.setCertificateEntry(alias, cert);
}
1

There are 1 answers

0
Puneet Kumar On BEST ANSWER

you can do the same task by using this way:

http://www.instructables.com/id/Publishing-an-Android-App-to-the-Google-Play-Store/?ALLSTEPS

it is easy and fast to work...