我正在使用php服務器在IOS中推送通知,並且我生成了應用程序的證書和密鑰,並且我確保從ssl://網關的unblocking端口.sandbox.push.apple.com:2196和2195,但在所有的時間,我得到嘗試在這個錯誤對SSL連接也是我從所有關鍵文件的權限當嘗試通過php文件執行Apple推送通知時出錯
Warning: stream_socket_client(): SSL: crypto enabling timeout in /Users/samahahmaed/Desktop/CER/newspush.php on line 24
Warning: stream_socket_client(): Failed to enable crypto in /Users/samahahmaed/Desktop/CER/newspush.php on line 24
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /Users/samahahmaed/Desktop/CER/newspush.php on line 24
Failed to connect: 0
編輯肯定:
當我嘗試這個命令時
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushCertificate.pem -key PushKey.pem -CApath /etc/ssl/certs/Entrust_Root_Certification_Authority.pem
我得到這個錯誤
CONNECTED(00000003)
write:errno=54
php文件:
<?php
// Put your device token here (without spaces):
$deviceToken = 'mydevicetokenhere';
// Put your private key's passphrase here:
$passphrase = '1234';
$message = $argv[1];
$url = $argv[2];
if (!$message || !$url)
exit('Example Usage: $php newspush.php \'Breaking News!\' \'https://raywenderlich.com\'' . "\n");
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apple_push_notification_production.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
// Open a connection to the APNS server
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array(
'alert' => $message,
'sound' => 'default',
'link_url' => $url,
);
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
// Close the connection to the server
fclose($fp);
我搜索了很多關於這個問題,我嘗試了所有可能的解決方案,但沒有任何結果,我現在可以做什麼?
編輯:
附加-debug OpenSSL的命令最奇怪的事情後,這些線路:
????? :(我試圖從這個問題2天沒有任何結果,直到現在:(((( –
正如@kerry在他們的答案中提出的,這似乎是一個證書問題。嘗試添加'-debug'標誌到你的'openssl你可以提供更多的信息來解決你的問題 – Palpatim
@Palpatim正如我對克里所說的那樣我試着對開發和生產證書的兩種情況以及同樣的結果進行了嘗試,我更新了我的帖子正如你在添加-debug到openssl命令之後所建議的那樣 –