idanappxoee / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

DerInputStream.getLength(): lengthTag=127, too big. #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
hi,

   when i call send notification method i get the following error.Plz help 
what is going wrong.

Original issue reported on code.google.com by preetipa...@gmail.com on 15 Apr 2010 at 1:25

GoogleCodeExporter commented 9 years ago
How many types of iPhone certificate are there?

Via keyChain, we got iPhone development certificate, but I don't know if 
iPhone development certificate is the same as iPhone push notification service
certificate?
iPhone development certificate =? iPhone push notification service certificate?

Thanks

Frank

Original comment by fwu2...@gmail.com on 25 Apr 2010 at 2:09

GoogleCodeExporter commented 9 years ago
I am not a Team Admin... according the to the APNS docs:
http://developer.apple.com/iphone/library/documentation/NetworkingInternet/Conce
ptual/RemoteNotificatio
nsPG/ProvisioningDevelopment/ProvisioningDevelopment.html#//apple_ref/doc/uid/TP
40008194-CH104-
SW1

(PDF: page 25-26)
In the iPhone Developer Program, each member on a development team has one of 
three roles: team agent, 
team admin, and team member. The roles differ in relation to iPhone development 
certificates and provisioning  
profiles. The team agent is the only person on the team who can create 
Development (Sandbox) SSLcertificates 
and Distribution (Production) SSLcertificates. The team admin and the team 
agent can both create both  
Development and Distribution provisioning profiles.

(PDF: page 26 gives the steps to creating the SSL Cert and keys)

Even as a 'Team member', the 'App ID' screen indicates whether APNS is enabled 
for a given provisioning 
profile. So... it would appear that the development certificate is part of the 
App ID cert. 

The project I'm involved with, there is a separate cert for dev & production... 
which the above seems to indicate 
that is not the norm.

Bill

Original comment by idbill.p...@gmail.com on 26 Apr 2010 at 2:35

GoogleCodeExporter commented 9 years ago
I got a success!
The following points should be paid attention to:

(1) iPhone development certificate != iPhone push notification service 
certificate
    There are a lot of iPhone certificates such as :
    * development
    * push server
    * game
(2) When you create your SSL push service Certificate (Apple), please ensure 
that 
    Enable for Apple Push Notification service is checked.

Thanks a lot!

Frank 

Original comment by fwu2...@gmail.com on 26 Apr 2010 at 6:20

GoogleCodeExporter commented 9 years ago
I've updated the [GetAPNSCertificate] wiki page with your comments.

Original comment by idbill.p...@gmail.com on 26 Apr 2010 at 7:54

GoogleCodeExporter commented 9 years ago
hi frank,

   can u please send me the steps required to create the certificate from a mac
machine...Even i have created the certificate file from my mac machine but no 
luck
yet...please guide me...

Thanks,
preeti 

Original comment by preetipa...@gmail.com on 27 Apr 2010 at 11:30

GoogleCodeExporter commented 9 years ago
Hi, Preeti :

Please check http://appnotify.com/developer/getting-started-push

Frank

Original comment by fwu2...@gmail.com on 27 Apr 2010 at 3:45

GoogleCodeExporter commented 9 years ago
Hey folks I need some guidance as I am getting java.net.ConnectException: 
Connection
timed out: connect. I am being waited for 8 - 9 seconds before I see this 
execption,
can any body throw some light on the issue.

import javapns.back.PushNotificationManager; 
 import javapns.back.SSLConnectionHelper; 
 import javapns.data.Device; 
import javapns.data.PayLoad; 
 public class Test { 
     // APNs Server Host & port 
     private static final String HOST = "gateway.sandbox.push.apple.com"; 
     private static final int PORT = 2195; 
     // Badge 
     private static final int BADGE = 66; 
     // iPhone's UDID (64-char device token) 
     private static String iPhoneId = "f4201f5d8278fe39545349d0868a24a3b60ed732"; 
     private static String certificate = "D:/certificate/NewAPNS_Certificate.p12"; 

    private static String passwd = "sat123"; 
 public static void main( String[] args ) throws Exception {System.out.println(
"Setting up Push notification" ); 
        try { 

             // Setup up a simple message 
             PayLoad aPayload = new PayLoad(); 
             aPayload.addBadge( BADGE ); 
             aPayload.addAlert("Hello! you have a new OVD Email");
             System.out.println( "Payload setup successfull." ); 
             System.out.println ( aPayload ); 
             // Get PushNotification Instance 
             PushNotificationManager pushManager =
PushNotificationManager.getInstance(); 
             // Link iPhone's UDID (64-char device token) to a stringName 
             pushManager.addDevice("iPhone", iPhoneId); 
             System.out.println( "iPhone UDID taken." ); 
             System.out.println( "Token: " + pushManager.getDevice( "iPhone"
).getToken() ); 
             // Get iPhone client 
             Device client = pushManager.getDevice( "iPhone" ); 
             System.out.println( "Client setup successfull." ); 
             // Initialize connection
             pushManager.initializeConnection( HOST, PORT, certificate, passwd,
SSLConnectionHelper.KEYSTORE_TYPE_PKCS12); 
             System.out.println( "Connection initialized..." ); 
             // Send message 
             pushManager.sendNotification( client, aPayload ); 
             System.out.println( "Message sent!" ); 
             System.out.println( "# of attempts: " + pushManager.getRetryAttempts() ); 
             pushManager.stopConnection(); 
             System.out.println( "done" ); 
         } catch (Exception e) { 
             e.printStackTrace(); 
         } 
     } 
 }

Original comment by sumitvya...@gmail.com on 11 May 2010 at 6:24

GoogleCodeExporter commented 9 years ago
java.net.ConnectException: Connection timed out: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:519)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:550)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:353)
    at
com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryI
mpl.java:71)
    at javapns.back.SSLConnectionHelper.getSSLSocket(Unknown Source)
    at javapns.back.PushNotificationManager.initializeConnection(Unknown Source)
    at Test.main(Test.java:36)

Original comment by sumitvya...@gmail.com on 11 May 2010 at 6:25

GoogleCodeExporter commented 9 years ago
Connection timed out...

What happens when you type this in your shell:
telnet gateway.sandbox.push.apple.com 2195

?

Original comment by idbill.p...@gmail.com on 11 May 2010 at 7:28

GoogleCodeExporter commented 9 years ago
Hi there,

I'm running at jdk 1.5 and it doesn't work (see the error below). Running 
exactly the
same thing at jdk 1.6 works fine.

java.io.IOException: DerInputStream.getLength(): lengthTag=127, too big.
        at com.ibm.security.util.DerInputStream.getLength(Unknown Source)
        at com.ibm.security.util.DerInputStream.getLength(Unknown Source)
        at com.ibm.security.util.DerValue.<init>(Unknown Source)
        at com.ibm.security.util.DerInputStream.getDerValue(Unknown Source)
        at com.ibm.security.pkcsutil.PKCSDerObject.decode(Unknown Source)
        at com.ibm.security.pkcs12.AuthenticatedSafe.<init>(Unknown Source)
        at com.ibm.security.pkcs12.BasicPFX.verifyMac(Unknown Source)
        at com.ibm.security.pkcs12.PFX.verifyMac(Unknown Source)
        at com.ibm.crypto.provider.PKCS12KeyStore.engineLoad(Unknown Source)

I'm using the following libraries:

javapns-jdk1.5-v1.6.jar
log4j-1.2.8.jar
commons-io-1.4.jar
commons-lang-2.5.jar
bcprov-jdk15-145.jar

I followed the instruction on Comment 8, but no success either.

Has someone managed to run this at 1.5 at all?

Thanks,
Daniel

Original comment by dani.ter...@gmail.com on 18 May 2010 at 2:26

GoogleCodeExporter commented 9 years ago
The error appears to relate to the certificate. Are you sure the java 1.5 
version is able to load the certificate?

I was able to send notifications using the same code on the WorkingExample Wiki 
page with Java 1.5 and the 
Java1.5 jars.

If you step thru the code where does it stop?

Bill

Original comment by idbill.p...@gmail.com on 18 May 2010 at 3:44

GoogleCodeExporter commented 9 years ago
Hi Bill,

See attached the output of loading the certificate. 

Likewise the WorkingExample works fine for me as long as I use Java 1.6, not 
1.5 though.

Thanks,
Daniel

Original comment by dani.ter...@gmail.com on 18 May 2010 at 4:09

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Bill,

Have you seen anything wrong on the loading?

Thanks,
Regards
Daniel

Original comment by dani.ter...@gmail.com on 21 May 2010 at 8:03

GoogleCodeExporter commented 9 years ago
Why are you including the jsacert install output?

Are you using an old version of the apns lib?
"Pre-1.6 version of importing Apple SSL Cert into Keystore"

note, this doesn't mean JAVA version, but apns version.

Bill

Original comment by idbill.p...@gmail.com on 5 Oct 2010 at 4:59

GoogleCodeExporter commented 9 years ago
no feedback...closing

Original comment by idbill.p...@gmail.com on 16 Oct 2010 at 9:38

GoogleCodeExporter commented 9 years ago
I got a success!
The following points should be paid attention to:

(1) iPhone development certificate != iPhone push notification service 
certificate
    There are a lot of iPhone certificates such as :
    * development
    * push server
    * game
(2) When you create your SSL push service Certificate (Apple), please ensure 
that 
    Enable for Apple Push Notification service is checked.

Thanks a lot!

Frank 

Thanks Frank It worked for me too.

Original comment by pankajav...@gmail.com on 12 Nov 2010 at 9:40

GoogleCodeExporter commented 9 years ago
compile action cause p12 file bad

Original comment by 315989...@qq.com on 12 Jan 2015 at 7:55