我正在尝试使用连接到ssl://gateway.push.apple.com:2195的简单
PHP工具发送手机推送通知,但连接失败并显示以下错误:
Warning: stream_socket_client(): SSL operation Failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify Failed in <Users/.../file.PHP> on line 30 Warning: stream_socket_client(): Failed to enable crypto in <Users/.../file.PHP> on line 30 Warning: stream_socket_client(): unable to connect to ssl://gateway.sandBox.push.apple.com:2195 (Unknown error) in <Users/.../file.PHP> on line 30 Failed to connect: 0
这一切都是从我升级到GMOS Sierra的GM Seed开始的.
macOS Sierra的新增功能会影响SSL连接?
我该如何解决?
解决方法
我有同样的错误,这就是我所做的:
1)更新我的openssl(我认为你不需要这个)得到第2步,因为这将需要大约10分钟
brew install openssl
确保你更新它是正确的:
openssl version
如果没有,请尝试此或谷歌:
brew link --force openssl
2)检查你的PHP default_cert_file路径:
PHP -r "print_r(openssl_get_cert_locations());"
这是我得到的:
Array ( [default_cert_file] => /usr/local/libressl/etc/ssl/cert.pem [default_cert_file_env] => SSL_CERT_FILE [default_cert_dir] => /usr/local/libressl/etc/ssl/certs [default_cert_dir_env] => SSL_CERT_DIR [default_private_dir] => /usr/local/libressl/etc/ssl/private [default_default_cert_area] => /usr/local/libressl/etc/ssl [ini_cafile] => [ini_capath] => )
3)从这里下载cacert.pem:
wget http://curl.haxx.se/ca/cacert.pem
4)将cacert.pem文件移动到您的default_cert_file路径(以root用户身份):
sudo mv cacert.pem /usr/local/libressl/etc/ssl/cert.pem
可能我需要先创建这个目录
之后,我的PHP脚本工作.