检测苹果推送证书有效性

   apple 推送程序,经常遇到发送失败或接收不到的问题.  

   以下收集了相关问题

   转至http://www.haodaima.net/art/2420853


使用APNS 搭建苹果推送服务器错误:unable to connect to ssl://gateway.sandbox.push.apple.com:2195 错误

1:检查你的服务器的端口 2195是否已经开启,是否被关闭了或是防火墙阻止了!这点很重要;

    如果你不确定,又出现了错误,请先向你的服务器商询问一下,并开启;

2:确认你的证书没有问题:

   在mac下执行 openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key-noenc.pem -debug -showcerts -CAfile "apns-dev.pem"

   在上面进程执行完之后;可以随便输入一些字符串,如果关闭了,这时是正常的!如果没有关闭,会有错误信息打印;说明证书有问题;

  证书生成:https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/

3:检查你的 推送程序是否有问题; 

   在这里推荐几个我测试成功的 php推送程序;

  •  https://github.com/blommegard/APNS-Pusher
  • https://github.com/duccio/ApnsPHP
  • https://github.com/manifestinteractive/easyapns
  • 其他:
    <?php //接收到设备发来的token,这里我手动填上。 $deviceToken = "c9d15180ff117c6540e0f21f8c13edae6a5a437e517acbac7bb740fd33b9b069"; //构造消息体 $body = array("aps" => array("alert" => 'this is test from push.cocoajin.org/p.php', "badge" => 1, "sound" => 'received5.caf')); $ctx = stream_context_create(); stream_context_set_option($ctx, "ssl", "local_cert", "apns-dev.pem"); //建立socket连接 $fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); if (!$fp) { print "Failed to connect $err $errstrn"; return; } print "Connection OK"; $payload = json_encode($body); $msg = chr(0) . pack("n",32) . pack("H*", $deviceToken) . pack("n",strlen($payload)) . $payload; print "sending message :" . $payload . "\n"; fwrite($fp, $msg); fclose($fp); ?> 

      

4:检查你的服务器与推送程序的环境配置是否相匹配;

    比如我的服务器使用Apache ,程序用php 那么 就要确认服务器 支持php 的 socket连接 openSSL模块;


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值