php 苹果推送通知服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1481443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:45:51  来源:igfitidea点击:

Apple Push Notification Service

phpmacosopensslapple-push-notifications

提问by Kamal Challa

i tried to run using local mac machine but go the following errors

我尝试使用本地 mac 机器运行,但出现以下错误

Warning: stream_socket_client() [function.stream-socket-client]: Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/apns/apns-dev.pem' in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 9

Warning: socket_close() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 11

Warning: fclose() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/apns/apns.php on line 12

I got PEM certificated generated from other machine,

我获得了从其他机器生成的 PEM 证书,

So I am totally confused what I have to do now.

所以我完全困惑我现在必须做什么。

Please let me know what I need to do to run it in localhost

请让我知道我需要做什么才能在本地主机中运行它

回答by jessecurry

I think that you may have exported the certificate, but not the private key from the .cer file that apple supplies.

我认为您可能已经导出了证书,但没有从苹果提供的 .cer 文件中导出私钥。

These instructions from markbates might help out:

马克贝茨的这些说明可能会有所帮助:

Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this:

  1. Click the disclosure arrow next to your certificate in Keychain Access and select the certificate and the key.
  2. Right click and choose Export 2 items….
  3. Choose the p12 format from the drop down and name it cert.p12.

Now covert the p12 file to a pem file:

获得 Apple 为您的应用程序提供的证书后,将您的密钥和 Apple 证书导出为 p12 文件。以下是有关如何执行此操作的快速演练:

  1. 在 Keychain Access 中单击您的证书旁边的披露箭头,然后选择证书和密钥。
  2. 右键单击并选择Export 2 items…
  3. 从下拉列表中选择 p12 格式并将其命名为cert.p12.

现在将 p12 文件转换为 pem 文件:

$ openssl pkcs12 -in cert.p12 -out apple_push_notification_production.pem -nodes -clcerts