我有一个包含以下内容的 PHP 文件,可以在开发证书上完美运行,但是当我切换到生产证书时,PHP 错误并给出以下消息,但它只有大约 50% 的时间这样做。其余 50% 有效。有谁知道为什么会发生这种情况?
<?php
// masked for security reason
$deviceToken = 'xxxxxx'; // jq
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', dirname(__FILE__)."/prod.pem");
$number = 5;
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstr\n";
}
else {
print "Connection OK\n";
$msg = $_GET['msg'];
$payload['aps'] = array('alert' => $msg, 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);
}
?>
PHP错误:
警告:stream_socket_client() [function.stream-socket-client]:无法设置本地证书链文件`/var/www/vhosts/thissite.com/httpdocs/prod.pem';检查您的 cafile/capath 设置是否在第 19 行的 /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 中包含您的证书及其颁发者的详细信息
警告:stream_socket_client() [function.stream-socket-client]:未能在第 19 行的 /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 中创建 SSL 句柄
警告:stream_socket_client() [function.stream-socket-client]:无法在第 19 行的 /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 中启用加密
警告:stream_socket_client() [function.stream-socket-client]:无法连接到 /var/www/vhosts/thissite.com/ 中的 ssl://gateway.sandbox.push.apple.com:2195(未知错误)第 19 行 httpdocs/pushMessageLive.php 连接失败 0