ios信息推送 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshak

tags:    時間:2013-12-03 18:40:35
 求救  求救  求救
ios信息推送 異常 javax.net.ssl.SSLHandshakeException: Received fatal alert: handshak
我用java作為信息的推送伺服器,我的實現代碼為:
public class MainApnsSend {

    public static void main(String[] args) throws Exception {
        try {
         //089d1ee3 602f918e 790de225 e72dc024 6c64f5b1 98ab4106 afa0392c 9af5c472
//            、、089d1ee3602f918e790de225e72dc0246c64f5b198ab4106afa0392c9af5c472                       
            //String deviceToken = "e775b5892f3334427c14def8aa4d8189a4ec1c795020072f4baa7ee92e50b1db";//iphone手機獲取的token
              String deviceToken = "089d1ee3 602f918e 790de225 e72dc024 6c64f5b1 98ab4106 afa0392c 9af5c472";//iphone手機獲取的token

              PayLoad payLoad = new PayLoad();
              payLoad.addAlert("我的push測試");//push的內容
              payLoad.addBadge(10);//圖標小紅圈的數值
              payLoad.addSound("default");//鈴音
                        
              PushNotificationManager pushManager = PushNotificationManager.getInstance();
              pushManager.addDevice("iPhone", deviceToken);
          
                       
              //Connect to APNs
              /************************************************
                          測試的伺服器地址:gateway.sandbox.push.apple.com /埠2195 
              產品推送伺服器地址:gateway.push.apple.com / 2195 
              ***************************************************/
//              gateway.sandbox.push.apple.com
              String host= "gateway.sandbox.push.apple.com";
              int port = 2195;
//              String certificatePath= "/Users/jcjc/Desktop/push_p.p12";//導出的證書
              String certificatePath= "/Users/machd/Desktop/MJiao/apns/ApnsAppServer/src/zheli_dev_csr_private_key.p12";//導出的證書
              
              String certificatePassword= "zheli123";//此處注意導出的證書密碼不能為空因為空密碼會報錯
              pushManager.initializeConnection(host,port, certificatePath,certificatePassword, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
                        
//              SSLConnectionHelper.KEYSTORE_TYPE_JKS
              //Send Push
              Device client = pushManager.getDevice("iPhone");
             System.out.println("Device token:"+  client.getToken());
            
              pushManager.sendNotification(client, payLoad);
              
              
               pushManager.stopConnection();

              pushManager.removeDevice("iPhone");
              System.out.println("iphone推送 java代碼實現 ---- Success !!!!");
             }
             catch (Exception e) {
              e.printStackTrace();
              System.out.println("推送失敗:" + e.getMessage());
             }

    }
}

異常信息如下:
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
推送失敗:Received fatal alert: handshake_failure
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:136)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1720)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:954)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:632)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
------解決方案--------------------
有現成的庫JavaPNS拿來用就好了
------解決方案--------------------
有現成的庫JavaPNS拿來用就好了
------解決方案--------------------
謝謝 搞定了  
------解決方案--------------------
請問,你是怎麼解決的嗎?
------解決方案--------------------
樓主看下這個
http://stackoverflow.com/questions/1233206/sslhandshakeexception-unknown-ca-apns-java
------解決方案--------------------
------解決方案--------------------
我也遇到這個問題了,可以具體的告訴我一下 
這個問題 樓主是怎麼解決的嗎
------解決方案--------------------
到底是怎麼解決的啊, 望樓主詳解。
------解決方案--------------------
樓主不厚道 ,建議以後誰也不理他
------解決方案--------------------
請問樓主是怎麼解決的?

推薦閱讀文章

Bookmark the permalink ,來源:互聯網