我可以在开发环境中通过ck.pem
通过gateway.sandbox.push.apple.com
向iphone成功发送推送通知。
但我想访问feedback.sandbox.push.apple.com
,我收到的错误如下:
警告:stream_socket_client()[function.stream-socket-client]:SSL操作失败,代码为1. OpenSSL错误消息:错误:14094414:SSL例程:SSL3_READ_BYTES:在/ Applications / XAMPP / xamppfiles /中撤消了sslv3警报证书第8行的htdocs / iphone / freebackFromApple.php
警告:stream_socket_client()[function.stream-socket-client]:无法在第8行的/Applications/XAMPP/xamppfiles/htdocs/iphone/freebackFromApple.php中启用加密
警告:stream_socket_client()[function.stream-socket-client]:无法连接到/ Applications / XAMPP / xamppfiles / htdocs中的ssl://feedback.sandbox.push.apple.com:2196(未知错误)第8行的/iphone/freebackFromApple.php 无法连接反馈服务器:0
我的php代码如下:
<?php
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', '/Applications/XAMPP/xamppfiles/htdocs/iphone/share/ck.pem');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
stream_context_set_option($ctx, 'ssl', 'passphrase', '');
$fp = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $error, $errorString, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect feedback server: $error $errorString\n";
return;
else {
print "Connection to feedback server OK\n";
}
print "APNS feedback results\n";
while ($devcon = fread($fp, 38)) {
$arr = unpack("H*", $devcon);
$rawhex = trim(implode("", $arr));
$feedbackTime = hexdec(substr($rawhex, 0, 8));
$feedbackDate = date('Y-m-d H:i', $feedbackTime);
$feedbackLen = hexdec(substr($rawhex, 8, 4));
$feedbackDeviceToken = substr($rawhex, 12, 64);
print "TIMESTAMP:" . $feedbackDate . "\n";
print "DEVICE ID:" . $feedbackDeviceToken . "\n\n";
}
fclose($fp);
?>
答案 0 :(得分:1)
只需访问Apple的配置网站,尝试下载证书以再次合并到ck.pem,然后将其放入您的服务器站点。 它适用于我,你。
答案 1 :(得分:0)
看起来像证书错误。您是否在Apple的配置网站上查看了您的SSL证书是否是最新的?
您还必须在certfile旁边指定密钥文件。