APN通过macOS Sierra推送通知 [英] APNs push notification with macOS Sierra
问题描述
我正在尝试使用简单的PHP工具向我的手机发送推送通知,该工具连接到 ssl://gateway.push.apple.com:2195
,但是连接失败并出现以下错误:
I'm trying to send my phone a push notification using the simple PHP tool which connects to ssl://gateway.push.apple.com:2195
, but the connection fails with the following errors:
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
这一切都是在我升级到GM之后开始的macOS Sierra的种子。
macOS Sierra中有哪些新功能会影响SSL连接?
如何解决这个问题?
This all started since I upgraded to the GM Seed of macOS Sierra. What's new in macOS Sierra that affects SSL connections? How do I resolve this?
推荐答案
我得到了同样的错误,这就是我所做的:
I got same error, and this is what I did:
1)更新了我的openssl (我认为你不需要这个)到了第2步,因为这将需要大约10分钟
1) updated my openssl (i think u dont need this) got to step 2, cause this will take about 10 minutes
brew install openssl
确保你更新正确:
openssl version
如果没有,试试这个或谷歌:
If not, try this or google:
brew link --force openssl
2)检查你的php default_cert_file路径:
2) check you php default_cert_file path:
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:
3) download cacert.pem from here:
wget http://curl.haxx.se/ca/cacert.pem
4)将cacert.pem文件移动到default_cert_file路径(以root身份):
4) move cacert.pem file to your default_cert_file path (as root):
sudo mv cacert.pem /usr/local/libressl/etc/ssl/cert.pem
可能是我首先需要创建这个目录
在此之后,我的php脚本工作了。
After this, my php script worked.
这篇关于APN通过macOS Sierra推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!