APNs push notification with macOS Sierra

前端 未结 4 1900
长情又很酷
长情又很酷 2021-02-13 12:58

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 fo

4条回答
  •  走了就别回头了
    2021-02-13 13:25

    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

    PHP 5.6.27 (cli) (built: Oct 23 2016 11:47:58) 
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    

    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

     $streamContext = stream_context_create([
                'ssl' => [
                    'verify_peer'      => true,
                    'verify_peer_name' => true,
                    'cafile'           => '/path/to/bundle/entrust_2048_ca.cer',
                ]
            ]);
    

    It works as well .

提交回复
热议问题