Exception while reading p12 file

2,627 views
Skip to first unread message

Vivek Patidar

unread,
Dec 6, 2016, 11:57:29 PM12/6/16
to pushy
Hi,

Here is our code to read p12 file :

final ApnsClient apnsClient = new ApnsClientBuilder().setClientCredentials(new File("/var/cert/pushcert.p12"), "passkey").build();


And we are getting following exception while reading p12 file.

java.io.IOException: toDerInputStream rejects tag type 66
    sun
.security.util.DerValue.toDerInputStream(DerValue.java:847)
    sun
.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1883)
    java
.security.KeyStore.load(KeyStore.java:1445)
    com
.relayrides.pushy.apns.P12Util.getFirstPrivateKeyEntryFromP12InputStream(P12Util.java:40)
    com
.relayrides.pushy.apns.ApnsClientBuilder.setClientCredentials(ApnsClientBuilder.java:137)
    com
.relayrides.pushy.apns.ApnsClientBuilder.setClientCredentials(ApnsClientBuilder.java:111)



Please suggest us what's wrong with above code.

We are using pushy-0.8.1 version

j...@turo.com

unread,
Dec 11, 2016, 9:44:30 PM12/11/16
to pushy
It looks like you're trying to read a PEM file instead of a PKCS#12 file. If you open the file with a text editor, does it begin with a line that looks something like "-----BEGIN CERTIFICATE-----"?

-Jon

Vivek Patidar

unread,
Dec 12, 2016, 9:36:16 AM12/12/16
to pushy
Our Beginning of file is :

Bag Attributes
    friendlyName: Apple Development IOS Push Services: com.example.app
    localKeyID: 60 0E 3C 2B C3 B1 12 27 74 3C 88 4E 26 09 24 53 E0 6F 53 3B
subject=/UID=com.example.app/CN=Apple Development IOS Push Services: com.example.app/OU=37GTU8M3T6/C=US
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
-----BEGIN CERTIFICATE-----

Jon Chambers

unread,
Dec 12, 2016, 9:39:49 AM12/12/16
to Vivek Patidar, pushy
Right; so that's definitely a PEM file, not a PKCS#12 file. You'll need to convert that to a PKCS#12 file for Pushy to be able to read it. There's lots of good information about how to do this strewn about the internet at large, but https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1020 should get you to where you need to be.

-Jon

--
Pushy is an open-source Java library for sending APNs (iOS and OS X) push notifications. Pushy is brought to you by the engineers at RelayRides.
---
You received this message because you are subscribed to the Google Groups "pushy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages