Quantcast
Viewing latest article 19
Browse Latest Browse All 36

IAP: Unable to create encryption key, InvalidKeySpecException

I created my game in the My Games section of the Ouya Devs website.  I then downloaded the key.der file, and opened it in a Hex Editor (Hexplorer).  I copied the hex data, pasted it over the default data in the APPLICATION_KEY, and when this code is run:

  try { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(APPLICATION_KEY); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); mPublicKey = keyFactory.generatePublic(keySpec); } catch (Exception e) { Log.e(LOG_TAG, "Unable to create encryption key", e); }  

I get this exception:

E/IapSample( 1897): Unable to create encryption key

E/IapSample( 1897): java.security.spec.InvalidKeySpecException: java.lang.RuntimeException: error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag

Anyone see what I'm doing wrong?  The key I pasted in is the same number of bytes as in the IAPSample, and even the first 3 1/2 lines or so match up exactly, so it *seems* right.


Viewing latest article 19
Browse Latest Browse All 36

Trending Articles