My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
How2UseJavapns  
This article explains how to simply use javapns to send notifications
Deprecated
Updated Oct 18, 2011 by sype...@gmail.com

 *IMPORTANT*: 
 This page is *deprecated* and therefore contains outdated and/or invalid information. 
 Please go back to the [http://code.google.com/p/javapns/ Project Home] to get access to the latest version and information.


Get your certificate

If you wanna use javapns on a PC, the first thing you have to do is exporting your certificate and you private key as a p12 file, using KeyChain on a MAC.

To do this, just select both certificate and private key (associated to the application you wish to use to send notifications) in KeyChain, and the right click on one item, and select "Export 2 elements", give a name (for example : myCertificate.p12) and password (for example : p@ssw0rd) and then export as p12.

Once you did this, you can now copy this p12 file on your PC (for example C:/temp).

Working with javapns

Send a simple notification

Download javapns, and then add it to your java project classpath. To send notifications, you just need this :

 PayLoad simplePayLoad = new PayLoad();
 simplePayLoad.addAlert("My alert message");
 simplePayLoad.addBadge(45);
 simplePayLoad.addSound("default");
 Device client = PushNotificationManager.getInstance().getDevice("my_iPhone");
 PushNotificationManager.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 2195, "C:/temp/myCertificate.p12", "p@ssw0rd", SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
 PushNotificationManager.getInstance().sendNotification(client, simplePayLoad);
 

The created payload looks like

 {"aps":{"sound":"default","alert":"My alert message","badge":45}}
 

And thats it, enjoy !

Send a complex notification

 // Or create a complex PayLoad with a custom alert
 PayLoad complexPayLoad = new PayLoad();
 PayLoadCustomAlert customAlert = new PayLoadCustomAlert();
 // You can use addBody to add simple message, but we'll use
 // a more complex alert message so let's comment it
 // customAlert.addBody("My alert message");
 customAlert.addActionLocKey("Open App");
 customAlert.addLocKey("javapns rocks %@ %@%@");
 ArrayList parameters = new ArrayList();
 parameters.add("Test1");
 parameters.add("Test");
 parameters.add(2);
 customAlert.addLocArgs(parameters);
 complexPayLoad.addCustomAlert(customAlert);
 complexPayLoad.addBadge(45);
 complexPayLoad.addSound("default");
 complexPayLoad.addCustomDictionary("acme", "foo");
 complexPayLoad.addCustomDictionary("acme2", 42);
 ArrayList values = new ArrayList();
 values.add("value1");
 values.add(2);
 complexPayLoad.addCustomDictionary("acme3", values);
 Device client = PushNotificationManager.getInstance().getDevice("my_iPhone");
 PushNotificationManager.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 2195, "C:/temp/myCertificate.p12", "p@ssw0rd", SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
 PushNotificationManager.getInstance().sendNotification(client, complexPayLoad);
 

The resulted payload will look like

 {"aps":{"sound":"default","alert":{"loc-args":["Test1","Test",2],"action-loc-key":"Open App","loc-key":"javapns rocks %@ %@%@"},"badge":45},"acme3":["value1",2],"acme2":42,"acme":"foo"}
 

Comment by dvclaus...@gmail.com, Jul 26, 2009

I'm trying the simple example and I get this exception, any ideas?


java.io.IOException java.io.IOException: failed to decrypt safe contents entry: java.security.NoSuchAlgorithmException?: Cannot find any provider supporting 1.2.840.113549.1.12.1.2

at com.sun.net.ssl.internal.ssl.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1275) at java.security.KeyStore?.load(KeyStore?.java:1150) at javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:77) at javapns.back.PushNotificationManager?.initializeConnection(PushNotificationManager?.java:74) at com.test.commandline.Notify.sendNotification(Notify.java:57) at com.test.commandline.Notify.main(Notify.java:25) at sun.reflect.NativeMethodAccessorImpl?.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl?.invoke(NativeMethodAccessorImpl?.java:39) at sun.reflect.DelegatingMethodAccessorImpl?.invoke(DelegatingMethodAccessorImpl?.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.codehaus.mojo.exec.ExecJavaMojo?$1.run(ExecJavaMojo?.java:283) at java.lang.Thread.run(Thread.java:613)
Caused by: java.security.NoSuchAlgorithmException?: Cannot find any provider supporting 1.2.840.113549.1.12.1.2
at javax.crypto.Cipher.getInstance(DashoA12275?) at com.sun.net.ssl.internal.ssl.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1270) ... 11 more

Comment by julien.r...@gmail.com, Jul 26, 2009

Great API, it works like a charm ! Maybe you may write on your wiki that org.apache.commons.lang is required for this project ? Anyways, good job

Julien Rozé, France

Comment by michaelw...@gmail.com, Aug 23, 2009

Is there a way to contact you guys directly? I wrote a similar program and would like to trade code.

-Mike

Comment by michaelw...@gmail.com, Aug 23, 2009

I get this exception when trying run the code above in a main method()...

It doesn't need the specific iPhone's UDID?

Exception in thread "main" Unknown client

at javapns.back.DeviceFactory?.getDevice(DeviceFactory?.java:87) at javapns.back.PushNotificationManager?.getDevice(PushNotificationManager?.java:143) at com.myapp.APNSTest.main(APNSTest.java:29)

What was wrong with my declaration? please e-mai me at:

michaelwilson72 AT gmail.com

Comment by msaeed43, Aug 26, 2009

@michaelwilson72, You should add the device to PushNotificationManager?, like

PushNotificationManager?.getInstance().addDevice("my_iPhone", "<device_token>");

It is the device token that has to be added not the udid.

Comment by ananth8...@gmail.com, Aug 28, 2009

I need some help in device token.whether the device token should be UUID(like 00000000-0000-1000-8000-0016CB957DE5).If i am passing UUID as a parameter its giving number format exception as it was expecting the integer in the send notification method.Can u guys tell me what exactly i need to do here PayLoad? simplePayLoad = new PayLoad?(); simplePayLoad.addAlert("My alert message"); simplePayLoad.addBadge(45); simplePayLoad.addSound("default"); PushNotificationManager?.getInstance().addDevice("my_iPhone", "00000000-00000-1000-8000-0016CB957DE5"); Device client = PushNotificationManager?.getInstance().getDevice("my_iPhone"); PushNotificationManager?.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 2195, "C:/temp/Certificates.p12", "password", SSLConnectionHelper.KEYSTORE_TYPE_PKCS12); PushNotificationManager?.getInstance().sendNotification(client, simplePayLoad);

Comment by Bilal.Al...@gmail.com, Aug 29, 2009

hello I keep getting this exception: Exception in thread "main" java.lang.NoClassDefFoundError?: org/apache/commons/lang/StringUtils?

at javapns.back.DeviceFactory?.addDevice(DeviceFactory?.java:65) at Test.<init>(Test.java:20) at Test.main(Test.java:37)
Caused by: java.lang.ClassNotFoundException?: org.apache.commons.lang.StringUtils?
at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController?.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader?.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader?.loadClass(Unknown Source) at java.lang.ClassLoader?.loadClass(Unknown Source) at java.lang.ClassLoader?.loadClassInternal(Unknown Source) ... 3 more

Comment by ananth8...@gmail.com, Aug 29, 2009

Hello bilal download commons-lang.jar and place the jar in your classpath

Comment by servert...@gmail.com, Sep 14, 2009

Im getting this on my macbook, the did and token are correct, the cert is choking on something.

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.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:77) at javapns.back.PushNotificationManager?.initializeConnection(PushNotificationManager?.java:74)

Comment by servert...@gmail.com, Sep 14, 2009

ok my bad I didnt export it....but theres no alert shoing up I only get sound.

Comment by paf...@gmail.com, Oct 1, 2009

Does someone success in passing UTF8 chars within a badge alert? I have got some issues with that. Resulting badges alerts are not well formed. For exemple, if the sended alert is "réussi" it will be transformed in "réussi"

Comment by paf...@gmail.com, Oct 1, 2009

UTF8 works fine, I was using a bad encoding.

Comment by Edison....@gmail.com, Oct 15, 2009

I Added FeedbackServiceManager? to the jar and attempted to retrieve the blacklisted devices. But I encountered the error “PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException?: unable to find valid certification path to requested target” Solved this issue with http://blogs.sun.com/andreas/entry/no_more_unable_to_find Then it simply worked fine.

Thanks,

Comment by bin...@gmail.com, Oct 27, 2009

Please help. I keep getting this "Received fatal alert: certificate_unknown" exception when the code tries to write to ssl socket's output stream. I got the certificate from the iPhone developer center, and export them as p12 file from my Mac.

Thank you very much.

Comment by bin...@gmail.com, Oct 28, 2009

I got my problem solved. I used the wrong certificate to make the connection. Another question: according to Mac's document, the socket for the push notification should always be open, but looks like what you're doing here is to quickly open a socket, send the notification, and close the socket. Is this the right way to do thing? by the way, when I tried to get the feedback by using the FeedbackServiceManager?, I got this "sun.security.validator.ValidatorException?: No trusted certificate found" exception. I am using the same p12 certificate for the push notification.

Thank you.

Comment by prudence...@gmail.com, Nov 5, 2009

Hi binshu,

I'm not answering your question, sorry, but I'm facing the "certificate_unknown" problem too. Could you please tell me what did you do with your environment. Did you just replace the ".p12" file? What was the right certificate on iPhone developer center and what was wrong? Your facts will truely helps us..

Thank you!

Comment by jpulikko...@gmail.com, Nov 5, 2009

the following is the working code try{

PayLoad? simplePayLoad = new PayLoad?(); simplePayLoad.addAlert("My alert message"); simplePayLoad.addBadge(1); simplePayLoad.addSound("default"); PushNotificationManager?.getInstance().addDevice("jijo's iPhone","give device token get from didRegisterForRemoteNotificationsWithDeviceToken delegate"); Device client = PushNotificationManager?.getInstance().getDevice("jijo's iPhone"); PushNotificationManager?.getInstance().initializeConnection("gateway.sandbox.push.apple.com", 2195, "C:/temp/APNSCertificates.p12", "paawordgivenwhenexport from keychain by click 'export 2 item' menu item", SSLConnectionHelper.KEYSTORE_TYPE_PKCS12); PushNotificationManager?.getInstance().sendNotification(client, simplePayLoad);

}catch(Exception e){

e.printStackTrace();
}

Comment by manne.ma...@gmail.com, Nov 6, 2009

hi Binshu,

Could you please let me know how exactly did you solve the problem? I have everything correctly done but still getting the same error "Received fatal alert: certificate_unknown". It would be great if you can help me stating the step by step procedure.

Thanks in advance.

Comment by flya...@gmail.com, Nov 10, 2009

I had a problem with a jailbroken 3.0 iPhone, the didRegisterForRemoteNotificationsWithDeviceToken was never called.

I installed "Push fix" using Cydia, that fixed it. Hope it helps someone.

Comment by flya...@gmail.com, Nov 10, 2009

I had a problem with a jailbroken 3.0 iPhone, the didRegisterForRemoteNotificationsWithDeviceToken was never called.

I installed "Push fix" using Cydia, that fixed it. Hope it helps someone.

Comment by bazwebb4@googlemail.com, Nov 10, 2009

Hi Guys, Great library, it's working really well for me. I now need to get the FeedbackServiceManager? going, but it doesn't seem to be available in the downloadable jar file. Am I doing something wrong? Or do I need to compile from source? If so, do you have any tips for compiling the source in eclipse (I'm not a Java programmer). Thanks, Baz

Comment by luke%luc...@gtempaccount.com, Nov 12, 2009

I was having the "certificate_unknown" problem too - I was my own fault. Make sure you export the two components as one and make sure you're using your push notification certificate and not your developer certificate (although I'm sure no-one else would be that silly!)

Comment by kamalmht...@gmail.com, Nov 17, 2009

Hi everyone, I tried using the library, but can anyone tell me how should be the device token be converted from binary to hex then to string..I have done this but didnt received any notification yet... Even the provider processes everything and I got a response from the provider, but yet no notification.... Did it failed silently? ...This is the code....

NSString dt = [description? stringByTrimmingCharactersInSet:characterSetWithCharactersInString:@"<>"?]; dt = stringByReplacingOccurrencesOfString:@" " withString:@""?; ......Is this correct way of converting?

Comment by kamalmht...@gmail.com, Nov 23, 2009

Hey bazwebb4,

Can you share with me what steps have you followed for the setup. I have done everything required but still not able to receive notifications.

Thanks

Comment by nxvs...@gmail.com, Dec 2, 2009

Hi, I have some problem in connecting ssl I think

java.io.IOException: toDerInputStream rejects tag type 66

sun.security.util.DerValue?.toDerInputStream(DerValue?.java:796) com.sun.net.ssl.internal.ssl.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1199) java.security.KeyStore?.load(KeyStore?.java:1150) javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:101) javapns.back.PushNotificationManager?.initializeConnection(PushNotificationManager?.java:81) ...

I use the code above and have it put to spring localhost.

Stephen

Comment by anil...@gmail.com, Dec 5, 2009

hi, i am getting the follwing exception when i try to send a notification:

java.io.IOException: DerInputStream?.getLength(): lengthTag=127, too big. java.io.IOException: DerInputStream?.getLength(): lengthTag=127, too big.

at sun.security.util.DerInputStream?.getLength(DerInputStream?.java:544) at sun.security.util.DerValue?.init(DerValue?.java:346) at sun.security.util.DerValue?.<init>(DerValue?.java:302) at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1200) at java.security.KeyStore?.load(KeyStore?.java:1185) at javapns.back.SSLConnectionHelper.getSSLSocket(Unknown Source) at javapns.back.PushNotificationManager?.sendNotification(Unknown Source)

Any help is appreciated.

Thanks

Comment by anil...@gmail.com, Dec 5, 2009

ignore my previous post, had the wrong p12 file

Comment by kalashni...@gmail.com, Dec 14, 2009

Did someone tried what idbill.planx.com suggested? I don't clearly understand the steps. Can someone outline what exactly should be done to get feedback service working. And what should be done to get some data from it? Does it work in a sandbox?

Comment by Bilal.Al...@gmail.com, Dec 16, 2009

Hi All,

I successfully integrated apple push notification to my application. I used Java server to send pushes to apple's sands box. I used a jar file for building the payload and send the notification to apple's server.

my problem is: Some times I received the push notification so fast and some times it takes like 3 minutes, I really don't know why. I debug my code and i discover that the problem is in a method in the APNS jar which is javapns.back.PushNotificationManager?.sendNotification()

Any one can help me in that , or giving me a hint why that happen

Comment by project member idbill.p...@gmail.com, Dec 30, 2009

Bilal.Allolo,

The delay doesn't surprise me in the least. Just like SMS messages, email and snail mail, there can be a delay in receiving the message because of the nature of the transport mechanism in place.

On Page 14 of the APNS docs it even alludes to this: Apple Push Notification Service includes a default Quality of Service (QoS) component that per forms a store-and-forward function.

Bill

Comment by Bilal.Al...@gmail.com, Jan 13, 2010

Hello All, Thanks for the great example. I done testing the push notification and now it is the time for production level. I configured the push notification SSL for production , I import the .p12 to my server side, I changed the url to gateway.push.apple.com, when I run the example my application did not receive a push notification, what I miss ? any one can help Thanks

Comment by shepherd...@gmail.com, Jan 15, 2010

When we do Device client = PushNotificationManager?.getInstance().getDevice("ourPNSID"); it says client not found.

When we do PushNotificationManager?.addDevice("name","ourPNSID") PushNotificationManager?.getInstance().getDevice("name"); it says device already exists.

Can you clarify?

Comment by Bilal.Al...@gmail.com, Jan 19, 2010

You mean the new certificate that I use for distribution? if that is what you mean , will I did not. I will try this.

Comment by Bilal.Al...@gmail.com, Jan 20, 2010

1) I created application ID. 2) Configure it to receive push notification for production. 3) create distribution profile for this application 4) creates a provision file. 5) Run the application using xcode to get a .app. 6) adds the ssl certificate to the server. 7) Send a push notification. No notification reached my iPhone ,,, what is missing?

Comment by thklc...@gmail.com, Jan 23, 2010

@Bilal.Allolo you have to close the app

Comment by project member idbill.p...@gmail.com, Jan 23, 2010

Bilal.Allolo,

Sorry, I don't know what has to occur on the iPhone side... BUT, the iPhoneId is created from the app ID and the push cert.

So, if the app id changes or the push cert changes, you will need to fetch a new iphoneId.

Comment by thklc...@gmail.com, Jan 24, 2010

@idbill.planx.com of course , but the messagebox etc will not apear

Comment by saisri....@gmail.com, Jan 25, 2010

Hello, is this push only for notifications of my application residing on iphone?. Is there a way to do the push from my custom calendar on java application server (iCal format data) to the iphone calendar? Thanks in advance

Comment by acuben...@googlemail.com, Jan 26, 2010

I got the same problem as Bilal.Allolo and it's still not solved. I send a push notification, I get no exception, but I don't receive a notification on my iPhone. Is there any possibility to receive a result message from the Apple Push Notification Service if a psuh notifiaction was sent successfully or not? When I call the FeedbackServiceManager?.getInstance().getDevices() method I got 0 devices. By the way, the FeedbackServiceManager? only works when I assign explicitly the keystore in my Java class via System.setProperty("javax.net.ssl.trustStore", "jssecacerts"); (I created jssecacerts with the class InstallCert?.java which is mentioned above)

Comment by Bilal.Al...@gmail.com, Jan 26, 2010

I still did not see why the application did not receive a push notification in production mode, while using the same steps for testing on sandbox ,, it works fine, even if my application is opened , I handled that case too. Any one can advice us for a very correct procedure to ward our goal in heaving the push notification for production works .. Thanks

Comment by acuben...@googlemail.com, Jan 27, 2010

@ Bilal.Allolo: Now I receive notifications! I think that you already receive notifications but you don't notice them. You still have to do:

1. Implement: - (void)applicationDidFinishLaunching:(UIApplication )application {

registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound)?;
} That means that you register your application for receiving notifications by alert dialog, alert sound and a badget number. 2. On your iPhone, check under "Settings" that you have activated notifications for your application receiving alert dialogs, alert sounds and badget numbers. Please take a look at http://mobiforge.com/developing/story/programming-apple-push-notification-services

Comment by wenhao...@gmail.com, Jan 27, 2010

Hi All,

The javapns is a good project and it works well with my app several days ago. But today when I tried to use a new cert file to do the push, I met the following erro:

java.io.IOException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded
	at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1277)
	at java.security.KeyStore.load(KeyStore.java:1185)
	at javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:101)
	at javapns.back.PushNotificationManager.initializeConnection(PushNotificationManager.java:101)

Is there anybody have ever met this issue before?

Thanks in advance.

Comment by nils.kai...@googlemail.com, Jan 28, 2010

Hi All,

the changes introduced to allow the use of an InputStream? to initialize the connection (Revision: 22, Author: maxime.peron, Date: 10:44:16, Monday, 30th of November 2009) have broken the retry code in PushNotificationManager?.sendNotifications. The retry code "this.socket = connectionHelper.getSSLSocket()" reads the input stream again, resulting in the following exception:

Caused by: java.io.IOException: DerInputStream?.getLength(): lengthTag=127, too big.

at sun.security.util.DerInputStream?.getLength(DerInputStream?.java:544) at sun.security.util.DerValue?.init(DerValue?.java:347) at sun.security.util.DerValue?.<init>(DerValue?.java:303) at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1200) at java.security.KeyStore?.load(KeyStore?.java:1185) at javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:101)

If you want to keep the possibility of loading the keystore from an InputStream?, which is useful for using with getClass().getResourceAsStream(), you'd have to add a factory interface called to return the InputStream?.

Greetings,

Nils

Comment by wenhao...@gmail.com, Jan 31, 2010

Please ignore my previous post. It is a certificate problem I made in creating the push certificate.

Comment by venu.mit...@gmail.com, Feb 1, 2010
wenhao.xu, I was getting this exception when my password was wrong..
Comment by mattkr...@gmail.com, Feb 7, 2010

My production server is behind a firewall. Does anyone know what I need to do to get the push notification stuff working when behind a firewall?

I've tried setting the various http.proxyHost, httpProxyPort system properties, but the code in SSLConnectionHelper that creates the socket seems to ignore any proxy settings and attempts to connect directly to the Apple servers.

Any help much appreciated. Running out of hair to tear out :)

Comment by ewing0...@gmail.com, Feb 8, 2010

when i try to run this program these have a run time error

java.io.IOException: DerInputStream?.getLength(): lengthTag=127, too big.

at sun.security.util.DerInputStream?.getLength(Unknown Source) at sun.security.util.DerValue?.init(Unknown Source) at sun.security.util.DerValue?.<init>(Unknown Source) at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(Unknown Source) at java.security.KeyStore?.load(Unknown Source) at javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:101) at javapns.back.PushNotificationManager?.sendNotification(PushNotificationManager?.java:144) at main.main(main.java:21)
how can i fix it

Comment by mattkr...@gmail.com, Feb 8, 2010

@idbill.planx.com

Thanks. Yes, Ive tried that. Doesnt seem to work. I can specify any URL, even an invalid one, and it will work on my Dev box.

I get the feeling the http proxy settings arent used by the code that executes a push notification. Is it perhaps because the interface is a binary TCP one, and not a HTTP/HTTPS one?

Comment by hadfieldn, Feb 11, 2010

I recently updated my certificate and now I'm getting this exception:

java.io.IOException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException?: Given final block not properly padded

at com.sun.net.ssl.internal.ssl.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1275) at java.security.KeyStore?.load(KeyStore?.java:1150) at javapns.back.SSLConnectionHelper.getSSLSocket(SSLConnectionHelper.java:101) at javapns.back.PushNotificationManager?.initializeConnection(PushNotificationManager?.java:81) ...
Caused by: javax.crypto.BadPaddingException?: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_h.b(DashoA12275?) at com.sun.crypto.provider.SunJCE_h.b(DashoA12275?) at com.sun.crypto.provider.SunJCE_ac.b(DashoA12275?) at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40.engineDoFinal(DashoA12275?) at javax.crypto.Cipher.doFinal(DashoA12275?) at com.sun.net.ssl.internal.ssl.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1272)

From what I've found so far, this typically means that the keystore password is incorrect, but I've verified that it is valid by using it to open the p12 file in Portecle.

Anyone else seen this? Could it be a Java 1.5 issue? Any ideas as to what might be wrong with my certificate? I've tried recreating it a few times without luck.

Comment by hadfieldn, Feb 11, 2010

Just a follow-up to the above: I have verified that the issue persists with Java 1.6.

Comment by hadfieldn, Feb 11, 2010

Okay, I'm an idiot. I confused Os and 0s in my password. When I entered the password in Portecle, I read them correctly (i.e., not what was in my code), so it worked.

You'd think I'd have figured this out right away, seeing that every post I could find about this exception was resolved by fixing the password...

Comment by hadfieldn, Feb 16, 2010

I finally got feedback working and thought I'd share some things I've learned in hopes it might save someone else some time:

  • Use the JVM argument -Djavax.net.debug=all to enable debug logging while loading keys and certificates and establishing the SSL handshake.
  • When you connect to feedback.[sandbox.]push.apple.com, the Apple server replies with a certificate that is not trusted by the default JAVA_HOME/lib/security/cacerts keystore. There are basically two ways around this: add trust for the certificate, or modify SSLConnectionHelper.java to simply trust whatever certificate is returned. (More on this below.)
  • The certificate Apple provides does not seem to be supported by the built-in Java security library. However, the BouncyCastle Crypto API does seem to support it.
  • The open source Portecle utility provides a helpful GUI for inspecting and modifying keystores.
  • Ad-hoc iPhone app distributions use the production servers (gateway.push.apple.com and feedback.push.apple.com), not the sandbox servers.
  • The Devices objects returned by FeedbackServiceManager?.getDevices() have a null 'id' and their 'lastRegister' property will be the date on which APN determined the application no longer exists on the device. You should compare this date against the date the device was last registered with your server to determine whether the device has been re-registered since it was recorded with the feedback service.

Method 1: Adding trust for everything

If you just want to get things working, you can modify SSLConnectionHelper.getSSLSocket() to simply trust everything. This makes you vulnerable to a man-in-the-middle attack, but it's quick and has fewer moving parts.

Modify SSLConnectionHelper.getSSLSocket():

	// TrustManager class that simply trusts all servers. Obviously this isn't very secure!!!
	public static class ServerTrustingTrustManager implements X509TrustManager {

		public void checkClientTrusted( X509Certificate[] chain, String authType ) throws 	CertificateException {
			throw new CertificateException( "Client is not trusted." );
		}
	
		public void checkServerTrusted( X509Certificate[] chain, String authType ) {
			// trust all servers
		}
	
		public X509Certificate[] getAcceptedIssuers() {
			return new X509Certificate[0];
		}
	}

	public SSLSocket getSSLSocket()throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException, KeyManagementException {
		// Load the Keystore
		KeyStore ks = KeyStore.getInstance(keystoreType);
		ks.load(new FileInputStream(this.keyStorePath), this.keyStorePass.toCharArray());
		

		// Get a KeyManager and initialize it 
		KeyManagerFactory kmf = KeyManagerFactory.getInstance(ALGORITHM);
		kmf.init(ks, this.keyStorePass.toCharArray());

		// Get the SSLContext to help create SSLSocketFactory			
		SSLContext sslc = SSLContext.getInstance(PROTOCOL);
		sslc.init(kmf.getKeyManagers(), new TrustManager[] { new ServerTrustingTrustManager() }, null);

		// Get SSLSocketFactory and get a SSLSocket
		SSLSocketFactory sslsf = sslc.getSocketFactory();
		SSLSocket socket; 

		if (proxySet) {
			. . .	// ommitted for brevity
		}else{
			socket = (SSLSocket) sslsf.createSocket(appleHost, applePort);			
		}		
		return socket;
	}

Method 2: Adding trust specifically for the Apple feedback certificate

If you want to check the Apple feedback certificate when initiating the SSL connection, you can do the following:

(1) Use the InstallCert.java file described above by Bill (Nov 27, 2009) to obtain the Apple feedback certificate.

(2) Add the certificate to your push notifications certificate keystore (*.p12). You can use the Java command-line utility keytool, but it's much easier to use Portecle.

(3) Download the BouncyCastle? crypto library for JDK 1.5 or JDk 1.6. Add it to your project's classpath.

(4) As described in the BC installation instructions, you will need to modify SSLConnectionHelper.java to add the BC security provider. You can do this with a static initializer somewhere inside the SSLConnectionHelper class:

	static {
		Security.addProvider(new BouncyCastleProvider());
	}

(5) Make a copy of the SSLConnectionHelper.getSSLSocket() method that will be used to get SSL sockets for feedback. The only difference will be that it will use your keystore to check trust, by initializing a TrustManagerFactory? with your keystore and passing its trust managers to the SSLContext init method. For brevity I have omitted the portion of getSSLSocket() that provides proxy support -- if (proxySet) { . . . } -- but it should still work fine here too.

	public SSLSocket getFeedbackSSLSocket()throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException, UnrecoverableKeyException, KeyManagementException {
		// Load the Keystore
		try {
			KeyStore ks = KeyStore.getInstance(keystoreType, "BC");
			ks.load(new FileInputStream(this.keyStorePath), this.keyStorePass.toCharArray());
		}
		catch( NoSuchProviderException e ) {
			throw RuntimeException( e );
		}
		

		// Get a KeyManager and initialize it 
		KeyManagerFactory kmf = KeyManagerFactory.getInstance(ALGORITHM);
		kmf.init(ks, this.keyStorePass.toCharArray());

		// Get a TrustManagerFactory and init with KeyStore
		TrustManagerFactory tmf = TrustManagerFactory.getInstance( ALGORITHM );
		tmf.init( ks );
		
		// Get the SSLContext to help create SSLSocketFactory			
		SSLContext sslc = SSLContext.getInstance(PROTOCOL);
		sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

		// Get SSLSocketFactory and get a SSLSocket
		SSLSocketFactory sslsf = sslc.getSocketFactory();
		SSLSocket socket = (SSLSocket) sslsf.createSocket(appleHost, applePort);			
		return socket;
	}

(6) Finally, modify FeedbackServiceManager?.getDevices() to use your new socket method:

	SSLSocket socket = connectionHelper.getFeedbackSSLSocket();
Comment by hadfieldn, Feb 16, 2010

One more thing: as Nils reported on Jan 28, 2010, the changes in r22 to support an InputStream? have broken the retry code in PushNotificationManager?.sendNotification(). On the second try, DerInputStream? throws an IOException.

The workaround for this is either to first call pushNotificationManager.setRetryAttempts(1) or, if you don't need to create the keystore from an InputStream?, just revert to r21.

Comment by anthony....@gmail.com, Feb 17, 2010

I got everything to run fine, but didnt see any sort of a push message. Perhaps some logging to know if things went OK or not would be in order. Looking at wireshark traces I dont see the payload anywhere so I am thinking there was an issue, but I dont know where to start checking.

Comment by anthony....@gmail.com, Feb 19, 2010

When sending the simple notification I get the the sounds that dings, and the badge bubble works too. But I dont actually get any message to pop up. Anyone have any ideas?

Comment by anthony....@gmail.com, Feb 19, 2010

FYI if I call toString() the alert looks like: {"aps":{"sound":"default","alert":"nothing shows up","badge":1}}

Comment by hadfieldn, Feb 23, 2010

Bill, thanks for making these improvements. This project is tremendously useful.

It looks like you fixed the broken retry code by instantiating the FileInputStream? in SSLConnectionHelper.getSSLSocket(). The problem in r22 was that this method, which is called during the retry, was attempting to reload the keystore with the same stream it loaded it from previously. On the second try, there would be nothing left in the stream, resulting in an IOException.

If you still want to provide the ability to pass in an input stream, you could create the keystore (or even the SSLSocketFactory) in the constructor, so that getSSLSocket() can get a new socket without having to reference the stream again.

Comment by paul.has...@gmail.com, Mar 9, 2010

try here as i seemed to have dropped a comment off in the wrong place...is there anything specific to java 1.6 that might prevent javapns compiling on another (older) JDK?

thanks.

Comment by maxime.f...@gmail.com, Mar 25, 2010

Hi

i am getting the follwing exception when i try to send a notification:

java.io.IOException: DerInputStream??.getLength(): lengthTag=127, too big.

Any help is appreciated.

Thanks

Comment by project member idbill.p...@gmail.com, Mar 25, 2010

The wiki is being expanded... please visit Intro before posting here.

Post questions/problems as issues under the issues tab... See Help

Comment by francksp...@gmail.com, Apr 20, 2010

Same error

java.io.IOException: DerInputStream???.getLength(): lengthTag=109, too big.

using http://blogs.sun.com/andreas/resource/InstallCert.java to retrieve the certificate of feedback.sandbox.push.apple.com

Comment by project member idbill.p...@gmail.com, Apr 20, 2010

The wiki is being expanded... please visit Intro before posting here.

Post questions/problems as issues under the issues tab... See Help

Comment by jhsol...@gmail.com, Apr 23, 2010

The current (4/23/2010) trunk implementation of the feedback service is not quite right, apparently. It contains this code to read from the service:

while ( socketStream.available() > 0 ) {
nbBytes = socketStream.read(b, 0, 1024); message.write(b, 0, nbBytes);
}

However, SSLSocketInputStream.available() can return zero even if input data is waiting to be read. See:

http://forums.sun.com/thread.jspa?threadID=5428561

I'd recommend changing the code to:

int nbBytes = 0; while((nbBytes = socketStream.read(b, 0, maxLength)) > 0) {
message.write(b, 0, nbBytes);
}
Comment by irtt.sen...@gmail.com, May 18, 2010

Hi,

I am trying to send notification in production mode. Everything goes fine and I am not getting any exception too when I run my sample. Also I am using the "gateway.push.apple.com" . But still i did not receive any notification in my device. Any help ?

thanks in advance.

Comment by vpian...@gmail.com, Jul 14, 2010

shepherdcrane?, to avoid DuplicateDeviceException?, use: pushManager.removeDevice("yourdevice");

Comment by ririneog...@gmail.com, Aug 24, 2010

Hi irtt.senthil, I have same problem, but on development

I am trying to send notification in development mode. Everything goes fine and I am not getting any exception too when I run my sample. Also I am using the "gateway.sandbox.push.apple.com" . But still i did not receive any notification in my device. Any help ?

thanks in advance.

Comment by Jeremy.J...@gmail.com, Sep 15, 2010

Im in the same situation of you riri... help us !

Comment by bzn...@gmail.com, Sep 29, 2010

javaapns client already exists

Comment by dbdelo...@gmail.com, Oct 26, 2010

I have gotten javapns working in my PC dev environment. Works like a charm. Now, however, I am trying to port it to my Android phone. Yeah, I know it sounds silly, pushing from an Android to an iPhone. Anyway, here's what I've found:

There seems to be a problem with log4j in Android. It runs out of memory and crashes in the build. So, I've changed all the logs to printlns. Also, I have had to change the KeyManagerFactory? ALGORITHM from "SunX509?" to "X509". Apparently the PC jre has some Sun libs that are not on Android. Now it builds fine and runs. However, now I am getting the following exception trying to write my push message.

Attempt to send Notification failed and beyond the maximum number of attempts permitted
java.io.IOException: SSL handshake failure: Failure in SSL library, usually a protocol error error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown (external/openssl/ssl/s3_pkt.c:1053 0x329b50:0x00000003)
at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.nativeconnect(Native Method) at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:305) at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl$SSLOutputStream.<init>(OpenSSLSocketImpl.java:546) at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.getOutputStream(OpenSSLSocketImpl.java:461) at back.PushNotificationManager?.sendNotification(PushNotificationManager?.java:136)

The SSLSocket opens just fine, but the exception happens when trying to open the OutputStream?. Anybody seen this before?

Looking in debug, the push cert and the distribution cert show up as trusted. However, my private key file shows up with isTrusted=false. On Android, the provider is BouncyCastle?, whether I add the bcprov lib to my build path.

This is my first SSL project, so these questions may seem rudimentary. But, I would greatly appreciate any help getting around this problem.

Thanks in advance.

Dave

Comment by alhala...@gmail.com, Nov 11, 2010

hi guys, I managed to run the demo, and send push notification. while trying to do this under the google app engine i got an exception as :

java.lang.ExceptionInInitializerError?

at javapns.back.PushNotificationManager?.initializeConnection(Unknown Source) at com.lemesee.server.servlets.UsersServlet?.doGet(UsersServlet?.java:149) at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:693) at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:806) at com.lemesee.server.servlets.AbstractServlet?.service(AbstractServlet?.java:39) at org.mortbay.jetty.servlet.ServletHolder?.handle(ServletHolder?.java:511) at org.mortbay.jetty.servlet.ServletHandler?.handle(ServletHandler?.java:390) at org.mortbay.jetty.security.SecurityHandler?.handle(SecurityHandler?.java:216) at org.mortbay.jetty.servlet.SessionHandler?.handle(SessionHandler?.java:182) at org.mortbay.jetty.handler.ContextHandler?.handle(ContextHandler?.java:765) at org.mortbay.jetty.webapp.WebAppContext?.handle(WebAppContext?.java:418) at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext?.handle(DevAppEngineWebAppContext?.java:70) at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327) at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126) at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl?.doRewrite(NormalRewrittenUrl?.java:213) at org.tuckey.web.filters.urlrewrite.RuleChain?.handleRewrite(RuleChain?.java:171) at org.tuckey.web.filters.urlrewrite.RuleChain?.doRules(RuleChain?.java:145) at org.tuckey.web.filters.urlrewrite.UrlRewriter?.processRequest(UrlRewriter?.java:92) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter?.doFilter(UrlRewriteFilter?.java:381) at org.mortbay.jetty.servlet.ServletHandler?$CachedChain?.doFilter(ServletHandler?.java:1157) at com.google.appengine.api.blobstore.dev.ServeBlobFilter?.doFilter(ServeBlobFilter?.java:58) at org.mortbay.jetty.servlet.ServletHandler?$CachedChain?.doFilter(ServletHandler?.java:1157) at com.google.apphosting.utils.servlet.TransactionCleanupFilter?.doFilter(TransactionCleanupFilter?.java:43) at org.mortbay.jetty.servlet.ServletHandler?$CachedChain?.doFilter(ServletHandler?.java:1157) at com.google.appengine.tools.development.StaticFileFilter?.doFilter(StaticFileFilter?.java:122) at org.mortbay.jetty.servlet.ServletHandler?$CachedChain?.doFilter(ServletHandler?.java:1157) at org.mortbay.jetty.servlet.ServletHandler?.handle(ServletHandler?.java:388) at org.mortbay.jetty.security.SecurityHandler?.handle(SecurityHandler?.java:216) at org.mortbay.jetty.servlet.SessionHandler?.handle(SessionHandler?.java:182) at org.mortbay.jetty.handler.ContextHandler?.handle(ContextHandler?.java:765) at org.mortbay.jetty.webapp.WebAppContext?.handle(WebAppContext?.java:418) at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext?.handle(DevAppEngineWebAppContext?.java:70) at org.mortbay.jetty.handler.HandlerWrapper?.handle(HandlerWrapper?.java:152) at com.google.appengine.tools.development.JettyContainerService?$ApiProxyHandler?.handle(JettyContainerService?.java:349) at org.mortbay.jetty.handler.HandlerWrapper?.handle(HandlerWrapper?.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection?.handleRequest(HttpConnection?.java:542) at org.mortbay.jetty.HttpConnection?$RequestHandler?.headerComplete(HttpConnection?.java:923) at org.mortbay.jetty.HttpParser?.parseNext(HttpParser?.java:547) at org.mortbay.jetty.HttpParser?.parseAvailable(HttpParser?.java:212) at org.mortbay.jetty.HttpConnection?.handle(HttpConnection?.java:404) at org.mortbay.io.nio.SelectChannelEndPoint?.run(SelectChannelEndPoint?.java:409) at org.mortbay.thread.QueuedThreadPool?$PoolThread?.run(QueuedThreadPool?.java:582)
Caused by: java.security.AccessControlException?: access denied (java.security.SecurityPermission? putProviderProperty.BC)
at java.security.AccessControlContext?.checkPermission(AccessControlContext?.java:323) at java.security.AccessController?.checkPermission(AccessController?.java:546) at java.lang.SecurityManager?.checkPermission(SecurityManager?.java:532) at com.google.appengine.tools.development.DevAppServerFactory?$CustomSecurityManager?.checkPermission(DevAppServerFactory?.java:166) at java.lang.SecurityManager?.checkSecurityAccess(SecurityManager?.java:1698) at java.security.Provider.check(Provider.java:386) at java.security.Provider.put(Provider.java:309) at org.bouncycastle.jce.provider.BouncyCastleProvider?.<init>(Unknown Source) at javapns.back.SSLConnectionHelper.<clinit>(Unknown Source)

any help please.

Comment by patrick....@gmail.com, Nov 20, 2010

@alhalayqa

I am afraid that you are not authorized to open an arbitrary outgoing connection using the App Engine. You are just authorized to do very limited things (like basic HTTP and HTTPS outgoing connections). I suppose this is the problem that you are getting.

If you need a possibility to send push notifications from the App Engine, you can use a service like Urban Airship. It's free up to a certain point.

Comment by patrick....@gmail.com, Nov 20, 2010

hi all,

I am wondering what is the standard workflow with Javapns to send a fair amount (e.g. 10'000) of notifications to different devices. Am I supposed to do batches of X notifications (e.g. 100), and open and close each time the connection before and after, then start again for the next batch? I suppose there is a limit about the number of notifications that Javapns (or Apple servers) can handle within the same connection (if yes, what is it)? Or does Javapns takes care about that itself?

Thanks in advance. Cheers,

Comment by bzu.ah...@gmail.com, Nov 23, 2010

my server does not give any errors BUT

I send the notification successfully from my provider to apple sandbox server but my client doesn't receive any notification

Comment by gregpear...@gmail.com, Dec 23, 2010

Running javapns version 1.6.3 and I have looked at the Wiki Help and Intro.

Still getting this error: Caused by: java.io.IOException: DerInputStream?.getLength(): lengthTag=109, too big.

at sun.security.util.DerInputStream?.getLength(DerInputStream?.java:544) at sun.security.util.DerValue?.init(DerValue?.java:347) at sun.security.util.DerValue?.<init>(DerValue?.java:303) at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1200) at java.security.KeyStore?.load(KeyStore?.java:1185) at javapns.back.SSLConnectionHelper.<init>(Unknown Source) at javapns.back.FeedbackServiceManager?.getDevices(Unknown Source)

Any help would be appreciated.

Comment by project member idbill.p...@gmail.com, Dec 24, 2010

Any comments here are ignored. Create a ticket to get answers.

Comment by raokai1...@gmail.com, Jan 5, 2011

any one meet with problems like follows:

" failed to decrypt safe contents entry: java.io.IOException: getSecretKey failed: PBE SecretKeyFactory? not available"

Comment by akash.te...@gmail.com, Feb 24, 2011

I have generated a .p12 file (on a mac) and am able to connect to apple push server without any issues on a windows machine.

But when i use the same on a linux box i get this error :

java.io.IOException: DerInputStream?.getLength(): lengthTag=127, too big

Do I need to generate some other certificate or file for linux ????

Comment by romkaen...@gmail.com, Mar 24, 2011

i just spend a half day finding out why my app doesnt receive push notifications. Everything was allright. No errors. But the notification didnt arrive on my test device. Finally i found out why. The time-settings on the device where wrong.

Check the time settings on your test-device if the pushnotification doesnt arrive

Comment by akin...@gmail.com, Apr 4, 2011

I am not sure how this is supposed to work. I can send a push the first time, but if I try again, I get a Client already exists error. Presumably because I added the device the first time around. So I tried to fix it by calling getDevice, then check if it's null before adding the device. However, now I am getting an unknown client exception.

        	PushNotificationManager pushManager = PushNotificationManager.getInstance();
        	// in javapns the device must have an id which apparently is unique.  I am therefore using the token for the id and the token so pushManager doesn't barf.
        	Device dev = pushManager.getDevice(deviceToNotify.deviceToken());
        	if(dev == null)
        		pushManager.addDevice(deviceToNotify.deviceToken(), deviceToNotify.deviceToken());
Comment by akin...@gmail.com, Apr 13, 2011

Ok, I solved that particular issue, though I still don't know what was intended. Now I'm trying to use the feedback example, but nothing seems to be happening. I am using it in the sandbox, but i am getting no devices back in my response, regardless of whether the devices have turned off notifications, been uninstalled, or what.

How is this supposed to work? Does the sandbox provide feedback? How can this be tested?

Comment by pkarata...@gmail.com, May 20, 2011

I've just solved my problem in using javapns. Solution could be interesting for someone else. I've read almost all info in code.google.com/p/javapns/wiki. I've done all things I've read to get notification on my iPhone. But I have not got it.

My mistake was the following. I've launched my iPhone app. It sends a signal to provider. Provider in turn sends push notification to the APNs. I've been waiting for some alert on my iPhone display but I've saw my usual app view.

Solution for me was the following. I've added delegate method

- (void)application:(UIApplication *)app didReceiveRemoteNotification:(NSDictionary *)notif {

NSLog(@"Push notification was received");
}

to the app delegate implementation file. Then I opened Console window in XCode, rebuild and restart my iPhone. And push notification was received indeed.

Comment by Apollo....@gmail.com, Aug 11, 2011

Depends on my company's network policy, i need to access APNs through proxy. so i add proxy setting as below: this.pushManager.setProxy(proxyHost, proxyPort); But proxy response error: startAPNManager Start APN manager create error: Unexpected EOF from proxy

first of all, i promise that my code is right, i test to access APNs directly without proxy, and i got notification on my iPhone. So what's wrong with my code? Is there any advices?

Comment by pzs.b...@gmail.com, Aug 22, 2011

I encountered one strange problem. PushNotificationManager?.getInstance().sendNotification(client, simplePayLoad); //My device can receive the message, but the application stopped after above line System.out.println("message sent"); //This line not executed

Comment by ketanv...@gmail.com, Aug 30, 2011

I tired the simple APNS code that describe in simple example but kept getting socket connection already close. Do anyone know what m'I doing wrong?

Comment by ketanv...@gmail.com, Sep 8, 2011

Ok i've finally solve the certificate issue but look like i've same issue previous user, i don't get the control back to my app after i call the method pushManager.sendNotification( client, aPayload )

Anything we need to do while initializeConnection ?

Comment by project member sype...@gmail.com, Sep 8, 2011

This is a known issue with 1.6 (see  issue #54 ), which has been fixed in 2.0 (Beta). If you can upgrade to that version, the issue should disappear.

Comment by nayak.ch...@gmail.com, Jan 2, 2012

Can I use this API for an Androi App. If yes then please send me how. Thanks...

Comment by project member sype...@gmail.com, Jan 2, 2012

No you cannot.

Comment by send2tes...@gmail.com, Feb 12, 2012

Hi I'm getting the below exception when i try to access apns. I dont have any clue. Anyone will be really appreciated. "ERROR javapns.notification.PushNotificationManager? - Delivery error : javapns.communication.exceptions.InvalidCertificateChainException?: Invalid cer tificate chain (Received fatal alert: certificate_unknown)! Verify that the key store you provided was produced according to specs..."

Comment by project member sype...@gmail.com, Feb 12, 2012

As stated at the top of this document, this page is deprecated and refers to an old version of JavaPNS. Please visit the project's web site to get the latest version and documentation. If you have an issue with the use of JavaPNS, please open an issue report in the Issues section.

Comment by gera.ka...@gmail.com, Apr 4, 2013

Hi i'm getting strange scenario i am able to send push notification successfully from server, but after sending some push notification certainly it start to throw exception

javapns.communication.exceptions.KeystoreException?: Keystore exception: exception decrypting data - java.security.InvalidKeyException?: Illegal key size

When i restart the server it started working fine again, but we cannot restart server again and gain, can any body tell what is root cause behind this.

thanks in advance

Comment by chiraggu...@gmail.com, Aug 8, 2013

Hi..... I have created the push message using this type of structure but I have faced one problem is that I got the message after the 2 to 5 hours any config are available in the api so we get the message instantly

any suggestion please mail me on chiraggurav@gmail.com

Comment by sarathk1...@gmail.com, Aug 18, 2013

Hi, as my input payload is correctbut iam getting response as "key"

can any body tell what will be the reason for this?

thanks in advance

Comment by mrishad...@gmail.com, Jun 30, 2014

Hello, I am using javapns and it work fine but everytime it sends a notification, it logs everything which is populating my log file. How can I stop logging when it sends a notification ? This is my code

`BasicConfigurator?.configure(); ArrayList?<String> devices = new ArrayList?<String>(); devices.add("device token"); Push.combined("Test Notification...", 1, "bingbong.aiff", "SSL_Cert.p12", "password", true, devices);`

(I have set production mode to true).

Thanks


Sign in to add a comment
Powered by Google Project Hosting