APNs push notification with macOS Sierra

前端 未结 4 1922
长情又很酷
长情又很酷 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:28

    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

    brew install openssl
    

    make sure u updated it correct:

    openssl version
    

    If not, try this or google:

    brew link --force openssl
    

    2) check you php default_cert_file path:

    php -r "print_r(openssl_get_cert_locations());"
    

    this is what i got:

    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) download cacert.pem from here:

    wget http://curl.haxx.se/ca/cacert.pem
    

    4) move cacert.pem file to your default_cert_file path (as root):

    sudo mv cacert.pem /usr/local/libressl/etc/ssl/cert.pem
    

    probably i'll need to create this directory first

    After this, my php script worked.

提交回复
热议问题