php - Apple 推送通知服务

标签 php macos openssl apple-push-notifications

我尝试使用本地 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

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

所以我完全不知道我现在必须做什么。

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

最佳答案

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

markbates 的这些说明可能会有所帮助:

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:

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

关于php - Apple 推送通知服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1481443/

相关文章:

c - C 中的 X509_NAME 宏无法编译

c - 关于使用 libssl 编程的任何好的例子?

php - 获取存储在 mySQL 上的完整 XML 结构

php - 显示产品类别

php - 如何使用 PHP 或仅使用 MySQL 在 MySQL 中重命名重复项

objective-c - CGFloat 与 GLfloat

PHP DOM 属性通配符

javascript - Canvas + CrossOrigin Anonymous + CORS + Chrome + Mac OS X

ios - 打开雷达有什么用?

OpenSSL RSA 引擎 - RSA 验证失败