当前位置:编程学习 > wap >>

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

 求救  求救  求救
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 --------------------编程问答-------------------- --------------------编程问答-------------------- 我也遇到这个问题了,可以具体的告诉我一下 
这个问题 楼主是怎么解决的吗 --------------------编程问答-------------------- 到底是怎么解决的啊, 望楼主详解。 --------------------编程问答-------------------- 楼主不厚道 ,建议以后谁也不理他 --------------------编程问答-------------------- 请问楼主是怎么解决的?
补充:移动开发 ,  iPhone
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,