我现在花了几天时间,试图让基本推送通知测试工作,但没有任何成功。半小时左右,我在Android上工作的东西也一样。
我尝试过的事情(没有mac)。
现在,令人困惑的部分是......在下面的代码中,哪个证书在哪里?
我的服务器是否甚至需要HTTPS连接?可以自签名吗。
我的简单演示看起来像这样(为简单起见,出现了一些变量):
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'passphrase', 'my_appache2_pass');
stream_context_set_option($ctx, "ssl", "local_cert", '/etc/apache2/ssl/mywebsite.com.pem');
stream_context_set_option($ctx, "ssl", "allow_self_signed", true);
stream_context_set_option($ctx, "ssl", "verify_peer", true);
stream_context_set_option($ctx, "ssl", "cafile", '/etc/apache2/ssl/Entrust.net-Certification-Authority-2048.pem');
$fp = stream_socket_client("tls://gateway.sandbox.push.apple.com:2195", $errno, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
//errors i keep getting
[Sat Oct 03 21:00:46.852453 2015] [:error] [pid 17460] [client 217.159.180.56:52870] PHP Warning: stream_socket_client(): SSL: Connection reset by peer in /var/www/html/ezleads_api/ApnsPHP/test.php on line 28
OR
[Sat Oct 03 21:01:36.033972 2015] [:error] [pid 17467] [client 217.159.180.56:52877] PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /var/www/html/ezleads_api/ApnsPHP/test.php on line 28
[Sat Oct 03 21:01:36.034157 2015] [:error] [pid 17467] [client 217.159.180.56:52877] PHP Warning: stream_socket_client(): Failed to enable crypto in /var/www/html/ezleads_api/ApnsPHP/test.php on line 28
[Sat Oct 03 21:01:36.034398 2015] [:error] [pid 17467] [client 217.159.180.56:52877] PHP Warning: stream_socket_client(): unable to connect to tls://gateway.sandbox.push.apple.com:2195 (Unknown error) in /var/www/html/ezleads_api/ApnsPHP/test.php on line 28
所以,我总共有3张证书:
push_cert.pem
已从Apple下载并转换目前,我只使用了2个证书。
我应该如何以及在哪里提供这些证书?