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
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 the same error after upgrading to macOS Sierra while using php script to send push notifications.
Solution with installing certificate to
[default_cert_file] => /usr/local/libressl/etc/ssl/cert.pem
didn't help as well.Updated to PHP v. 5.6.27, macOS Sierra 10.12.4
And after all, I found my problem. It was in the fact, that macOS Sierra updated PHP version to 5.6.27
To check it, type in Terminal
php -v
And here is OpenSSL changes in PHP 5.6.x
As the brief workaround, someone suggested disabling brand-new security features in the php script (in the link above, very bottom part).
Safer (and I recommend it) would be a way to setup path to entrust_2048_ca.cer explicitly like
It works as well .
You can get certificate from Entrust. Download the entrust_2048_ca.cer certificate from: https://www.entrust.com/get-support/ssl-certificate-support/root-certificate-downloads/. After downloading entrust_2048_ca.cer, I copied it in the same directory where my php script was and it all worked.
More details here: https://stackoverflow.com/a/28222783/4253579
adding to the answer given by @Sandar you can also set the cafile like this
I got same error, and this is what I did:
1) updated my openssl (i think u dont need this) got to step 2, cause this will take about 10 minutes
make sure u updated it correct:
If not, try this or google:
2) check you php default_cert_file path:
this is what i got:
3) download cacert.pem from here:
4) move cacert.pem file to your default_cert_file path (as root):
probably i'll need to create this directory first
After this, my php script worked.