0
votes

I can send push notification to iphone success with certificate ck.pem throught gateway.sandbox.push.apple.com in development environment.

But I want to access feedback.sandbox.push.apple.com, I got the error as follow:

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094414:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate revoked in /Applications/XAMPP/xamppfiles/htdocs/iphone/freebackFromApple.php on line 8

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /Applications/XAMPP/xamppfiles/htdocs/iphone/freebackFromApple.php on line 8

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://feedback.sandbox.push.apple.com:2196 (Unknown error) in /Applications/XAMPP/xamppfiles/htdocs/iphone/freebackFromApple.php on line 8 Failed to connect feedback server: 0

My php code as follows:

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

2 Answers

1
votes

Just go to Apple's provisioning website to try download the certificates to combine to ck.pem again, then put it to Your Server site. It works for me, ya.

0
votes

Looks like a certificate error. Have you checked on Apple's provisioning website whether your SSL certificates are up to date?

You also have to specify the keyfile, beside the certfile.