Friday, 27 September 2013

DER input, Integer tag error in push notifications sender

DER input, Integer tag error in push notifications sender

We use JavAPNS for sending push notifications to iOS devices. Push
notifications to iOS devices are sent and recieved, when I am in Windows
or OS X,but when I am in Linux environment this error occurs:
javapns.communication.exceptions.KeystoreException: Keystore exception:
DER input, Integer tag error
at
javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:178)
at
javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:66)
at
javapns.communication.KeystoreManager.ensureReusableKeystore(KeystoreManager.java:87)
at
javapns.communication.AppleServerBasicImpl.<init>(AppleServerBasicImpl.java:37)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:57)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:42)
at
javapns.notification.AppleNotificationServerBasicImpl.<init>(AppleNotificationServerBasicImpl.java:28)
at javapns.Push.sendPayload(Push.java:170)
at javapns.Push.payload(Push.java:149)
at com.myproj(class.java:80)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.io.IOException: **DER input, Integer tag error**
at sun.security.util.DerInputStream.getInteger(DerInputStream.java:151)
at
com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1202)
at java.security.KeyStore.load(KeyStore.java:1185)
at
javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:64)
... 11 more
This is my code:
public void run() {
List<PushedNotification> notifications = new
ArrayList<PushedNotification>();
String keystorePath = "/cert/cert.p12";
InputStream keystore = this.getClass().getResourceAsStream(keystorePath);
try {
//Some code..
payload = constructMessagePayload();
notifications = Push.payload(payload, keystore,"password",
false, iphoneTargets);
logger.info("Notification list size:" + notifications.size());
} catch (CommunicationException e) {
logger.error("Exception",e);
} catch (KeystoreException e) {
logger.error("Exception",e);
} catch (JSONException e) {
logger.error("Exception",e);
}
for (PushedNotification notification : notifications) {
if (pn.isSuccessful()) {
logger.info("Push ok: "
+ pn.getPayload().toString());
} else {
logger.info("Push not ok: "
+ pn.getException().toString());
}
}
}
If I specify absolute path of file everything works, but I want to have it
in src/main/resources, not to log into server every time when I need to
change file. If I correctly understand this is problem related with
private key.Is there a way this to be fixed.What is different in Linux
here? Any advices?

No comments:

Post a Comment