我跟着this問題消費APNS反饋服務。這是我請求反饋服務器的代碼;帶PHP的套餐推送通知反饋服務 - 套接字錯誤
function send_feedback_request() {
//connect to the APNS feedback servers
//make sure you're using the right dev/production server & cert combo!
$stream_context = stream_context_create();
stream_context_set_option($stream_context, 'ssl', 'local_cert', 'my_production_cerficate.pem');
$apns = stream_socket_client('ssl://feedback.push.apple.com:2196', $errcode, $errstr, 60, STREAM_CLIENT_CONNECT, $stream_context);
if(!$apns) {
die("ERROR $errcode: $errstr\n");
}
$feedback_tokens = array();
//and read the data on the connection:
while(!feof($apns)) {
$data = fread($apns, 38);
if(strlen($data)) {
$feedback_tokens[] = unpack("N1timestamp/n1length/H*devtoken", $data);
}
}
fclose($apns);
return $feedback_tokens;
}
當我使用此功能時,它會報告以下錯誤;
Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file /my_directories/my_production_cerficate.pem in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /my_directories/apnsfeedback.php on line 7
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://feedback.push.apple.com:2196 (Unknown error) in /my_directories/apnsfeedback.php on line 7
我用我生產證書(.PEM),我用來發送推送通知的消息,它的有效工作+。所以一個無效的證書在這裏不是問題。我在這裏做錯了什麼?
您是否在該文件中組合了cert + key?您的權限是否允許Web服務器讀取文件?密鑰是否由密碼保護?等等。 – 2013-04-08 13:54:48
我正在用push.php腳本在同一目錄中發送推送通知。所以是的,它有證書+密鑰。用於推送消息的常規pem文件。它是重點保護,但我不能設置密鑰,因爲它上升另一個錯誤,說密碼不能設置...我應該使用不同於我的普通推送通知證書的證書? – Bartu 2013-04-08 13:55:32