Push Notification in PHP using PEM file

后端 未结 4 1970
攒了一身酷
攒了一身酷 2020-12-08 11:45

I\'ve been working through Ray Wenderlich\'s tutorials on push notifications using a PHP Script.

Reference: http://www.raywenderlich.com/32960/apple-push-notificatio

相关标签:
4条回答
  • 2020-12-08 12:11

    Updated to macOS Sierra 10.12.4


    The problem is in new PHP Version in macOS Sierra. They changed the way it works with certificates.

    I would suggest a small changes in the accepted answer to make things explicit.

    You have to setup path to entrust_2048_ca.cer and other parameters during creation of the stream context like

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

    The full explanation and links are here

    0 讨论(0)
  • 2020-12-08 12:12

    Update to macOS sierra 10.12.5

    please add

    stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
    

    The problem is in new PHP Version in macOS Sierra

    0 讨论(0)
  • 2020-12-08 12:28

    Okay, I finally figured this out! After 2 days of working with this.

    So, for anyone else who runs into this issue:

    Download the entrust_2048_ca.cer certificate from: https://www.entrust.com/get-support/ssl-certificate-support/root-certificate-downloads/

    Scroll down and get the Entrust.net Certificate Authority (2048)

    Then, in the push.php file, after you set the context for the passphrase, add this line: stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');

    0 讨论(0)
  • 2020-12-08 12:31

    add

    stream_context_set_option($ctx, 'ssl', 'verify_peer', false);

    which defeats the server validation. Credits @One In a Million Apps in a comment above.

    0 讨论(0)
提交回复
热议问题