2016-08-14 4 views
2

phpサーバーでIOSでプッシュ通知を行っていて、アプリケーションの証明書と鍵を生成しました。また、ssl:// gatewayのポートをブロック解除しています.sandbox.push.apple.com:2196と2195が、私は、SSLに接続しようとした時に、このエラーを取得し、すべての時にも、私はすべてのキーファイルのパーミッションphpファイルを使ってApple Push Notificationを実行しようとするとエラーが発生する

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); 

を私はこの問題について多くのことを検索し、私はすべての可能な解決策を試してみましたが、私は今何ができるかどんな結果なし?

編集:

opensslコマンドに追加-debug最も奇妙なことした後、これらの行は:あなたがサンドボックスAPNSに接続するために、生産の証明書を使用しているよう enter image description here

+0

????? :(私は今まで何の結果もなかったので、この問題を2日間から試しています:((( –

+0

@kerryが回答で示唆したように、これは証明書の問題のようです) '-debug'フラグを' openssl – Palpatim

+0

@PalpatimがKerryに言ったように、私は開発と生産の証明書と同じ結果を2つのケースで試してみましたが、私はあなたの投稿を更新しましたあなたが提案したように-debugをopensslコマンドに追加しました –

答えて

0
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apple_push_notification_production.pem'); 

この線は見えます。開発証明書を使用してみてください。あなたはリンゴの開発者のダッシュボードから同じものを得ることができます。

+0

私は2つのケースをエラーに変更せずに使用しましたが、ここでは証明書のこの名前だけを忘れています –

関連する問題