I need to develop a PHP class to communicate with Apple servers in order to make push notification (APNS). I have a certificate (.pem) and I tried to follow various tutorials found on the Internet, but I still get an error trying to connect to ssl: //gateway.sandbox.push.apple.com: 2195 with a streaming socket :
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = 'apns-dev.pem';
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://'.$apnsHost.':'.$apnsPort, $error, $errorString, 2,
STREAM_CLIENT_CONNECT, $streamContext);
Telnet works on this URL, so port 2195 is open. Openssl is activated in PHP since I get "Registered Socket Transports: tcp, udp, ssl, sslv3, sslv2, tls" with phpinfo (). My certificate is well readable (PHP is_readable (certif.pem) returns true in the file)
Is there anything else to activate in Apache or PHP to make it work?
Anth0 source
share