javapns-jdk16 icon indicating copy to clipboard operation
javapns-jdk16 copied to clipboard

Invalid keystore format! Make sure it is PKCS12...

Open shangguanjiang opened this issue 9 years ago • 0 comments

Hi, I need to use javaapns loop to push the message,The first message is a success。Later there will be a mistake。What should I do to avoid these?

look my code:

Test main

ApnsTest apnsTest = new ApnsTest(); List<String> devices = new ArrayList<String>(); devices.add("3b9fc52cf1df226e9aeb2ae90b6e94c4ef8144f0de2418ec170d5ee96ea3a3da"); for (int i = 0; i < 3; i++) { apnsTest.send(devices, keystore, password, true); }

ApnsTest

`public void send (List<String> devices, Object keystore, String password, boolean production) { PushNotificationPayload payload = PushNotificationPayload.complex(); try { payload.addAlert("Hello World!"); payload.addSound("defult"); payload.addCustomDictionary("url", "http://www.baidu.com"); payload.addCustomDictionary("type", "Url"); // etc. payload.addCustomDictionary("pushId",111); // etc. payload.addCustomDictionary("forumkey","sadasds"); // etc. List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, devices); for (PushedNotification notification : notifications) { if (notification.isSuccessful()) { System.out.println("Push notification sent successfully to: " + notification.getDevice().getToken()); } else { String invalidToken = notification.getDevice().getToken();

                        System.out.println("invalidToken :"+invalidToken);
                        ResponsePacket theErrorResponse = notification.getResponse();
                        if (theErrorResponse != null) {
                            System.out.println(theErrorResponse.getMessage());
                        }
                    }
            }


    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (CommunicationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (KeystoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    }   `

error: `Push notification sent successfully to: 3b9fc52cf1df226e9aeb2ae90b6e94c4ef8144f0de2418ec170d5ee96ea3a3da javapns.communication.exceptions.InvalidKeystoreFormatException: Invalid keystore format! Make sure it is PKCS12... at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:172) at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:66) at javapns.communication.KeystoreManager.ensureReusableKeystore(KeystoreManager.java:87) at javapns.communication.AppleServerBasicImpl.(AppleServerBasicImpl.java:37) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:57) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:42) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:28) at javapns.Push.sendPayload(Push.java:170) at javapns.Push.payload(Push.java:149) at com.goyoo.test.ApnsTest.send(ApnsTest.java:71) at com.goyoo.test.ApnsTest.main(ApnsTest.java:53) javapns.communication.exceptions.InvalidKeystoreFormatException: Invalid keystore format! Make sure it is PKCS12... at javapns.communication.KeystoreManager.wrapKeystoreException(KeystoreManager.java:172) at javapns.communication.KeystoreManager.loadKeystore(KeystoreManager.java:66) at javapns.communication.KeystoreManager.ensureReusableKeystore(KeystoreManager.java:87) at javapns.communication.AppleServerBasicImpl.(AppleServerBasicImpl.java:37) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:57) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:42) at javapns.notification.AppleNotificationServerBasicImpl.(AppleNotificationServerBasicImpl.java:28) at javapns.Push.sendPayload(Push.java:170) at javapns.Push.payload(Push.java:149) at com.goyoo.test.ApnsTest.send(ApnsTest.java:71)

at com.goyoo.test.ApnsTest.main(ApnsTest.java:53)`

thank

shangguanjiang avatar Jun 02 '16 03:06 shangguanjiang