5

I'm tring to load p12 for send APNS notifications with:

InputStream in = new FileInputStream(certPath);
KeyStore ks = KeyStore.getInstance("PKCS12");
ks.load(in, certPass.toCharArray());

Error when execute on bluemix liberty runtime with IBM jdk.

java.io.IOException: insufficient data
at com.ibm.security.util.DerInputBuffer.truncate(Unknown Source)
at com.ibm.security.util.DerValue.(Unknown Source)
at com.ibm.security.util.DerInputStream.getDerValue(Unknown Source)
at com.ibm.security.pkcs12.BasicPFX.decode(Unknown Source)
at com.ibm.security.pkcs12.PFX.decode(Unknown Source)
at com.ibm.security.pkcsutil.PKCSDerObject.decode(Unknown Source)
at com.ibm.security.pkcs12.PFX.(Unknown Source)
at com.ibm.crypto.provider.PKCS12KeyStoreOracle.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)

Error when execute on bluemix liberty runtime with openjdk:

java.io.IOException: insufficient data
at sun.security.util.DerInputBuffer.truncate(DerInputBuffer.java:125)
at sun.security.util.DerInputStream.subStream(DerInputStream.java:136)
at sun.security.util.DerInputStream.readVector(DerInputStream.java:381)
at sun.security.util.DerInputStream.getSequence(DerInputStream.java:298)
at sun.security.pkcs.ContentInfo.(ContentInfo.java:132)
at sun.security.pkcs.ContentInfo.(ContentInfo.java:109)
at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1247)
at java.security.KeyStore.load(KeyStore.java:1214)

Ejecutando un listado del contenido del amacen:

keytool -list -keystore apns-certificate-sandbox.p12 -storepass ****-storetype PKCS12 -v

Tipo de Almac▒n de Claves: PKCS12
Proveedor de Almac▒n de Claves: SunJSSE

Su almac▒n de claves contiene 1 entrada

Tipo de Entrada: PrivateKeyEntry
Longitud de la Cadena de Certificado: 1
Certificado[1]:
Propietario: C=US, OU=HK5F55SZAU, CN=Apple Development IOS Push Services: com.kramagot.test, UID=com.kramagot.test
Emisor: CN=Apple Worldwide Developer Relations Certification Authority, OU=Apple Worldwide Developer Relations, O=Apple Inc., C=US
...
 Nombre del Algoritmo de Firma: SHA1withRSA
         Versi▒n: 3
...
  • Do you know what encryption the certificates in the PKCS12 keystore use? Maybe follow the instruction here (http://stackoverflow.com/questions/14375235/how-to-list-the-certificates-stored-in-a-pkcs12-keystore-with-keytool) to list the keystore contents but be sure not to post any sensitive information here regarding the keystore contents. – Finbarr O'B Jul 21 '16 at 19:05
  • Edit the question with that info – Miguel Ángel Hernández Castro Jul 22 '16 at 07:27
  • It appears that the input stream is pointing to an new (empty) file. Can you confirm that `certPath` used to create the input stream `in` is referring to the correct path in the Bluemix deployment environment? Consider using an absolute path like `new FileInputStream(new File(parent, certPath))`. – Saïd Jul 25 '16 at 16:19
  • I print the fileinputstream and it has the content. – Miguel Ángel Hernández Castro Jul 25 '16 at 19:19
  • I agree with @saheed, you want to ensure that the path being loaded is correct for Bluemix. – RandalAnders Aug 09 '16 at 15:19

0 Answers0