在 LINUX w 下使用 PHP 从推送通知创建 .pem 文件 [英] Creating .pem file from pushnotification with PHP under LINUX w

查看:22
本文介绍了在 LINUX w 下使用 PHP 从推送通知创建 .pem 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中实现推送通知,为此我尝试使用 easyApns,我按照步骤操作,并在我的基于 linux 的上实现了这些类.但不幸的是,我仍然打赌一些与证书相关的错误.

i'm trying to implement push notification in my application, for this i tried to use easyApns, i follow the steps, and implement the classes on my linux based. but unfortunately i stil betting some errors related to certificates.

我的错误是:

警告:stream_socket_client() [function.stream-socket-client]:SSL操作失败,代码 1.OpenSSL 错误消息:错误:14094416:SSL 例程:SSL3_READ_BYTES:sslv3 警报证书在第 401 行的/var/www/html/apns/classes/class_APNS.php 中未知

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown in /var/www/html/apns/classes/class_APNS.php on line 401

警告:stream_socket_client() [function.stream-socket-client]:无法在/var/www/html/apns/classes/class_APNS.php 中启用加密在线 401

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /var/www/html/apns/classes/class_APNS.php on line 401

警告:stream_socket_client() [function.stream-socket-client]:无法连接到 ssl://gateway.sandbox.push.apple.com:2195(未知错误)在/var/www/html/apns/classes/class_APNS.php 上线401

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /var/www/html/apns/classes/class_APNS.php on line 401

注意:无法连接到 APNS:0.1) APNS::__construct -> 文件:apns.php(第 50 行)2)APNS::_fetchMessages -> 文件:class_APNS.php(第 217 行)3)APNS::_pushMessage -> 文件:class_APNS.php(第 376 行)4)APNS::_triggerError -> File: class_APNS.php (line 405) in/var/www/html/apns/classes/class_APNS.php 第 509 行

Notice: Failed to connect to APNS: 0 . 1) APNS::__construct -> File: apns.php (line 50) 2) APNS::_fetchMessages -> File: class_APNS.php (line 217) 3) APNS::_pushMessage -> File: class_APNS.php (line 376) 4) APNS::_triggerError -> File: class_APNS.php (line 405) in /var/www/html/apns/classes/class_APNS.php on line 509

我猜这是与证书(.pem 文件)相关的错误

i gusse it's an error related to the certificate (the .pem file)

使用以下命令生成我的 .pem 文件

my .pem file wa generated using the following command

openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts

openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts

它被放置在服务器上(基于 linux)并被授予 chmod 644 权限

and it was placed on the server (linux based) and given chmod 644 privileges

我应该做点别的吗.....

should i do any thing else.....

推荐答案

您是否能够使用您的证书连接到 apns?尝试以下命令来检查:

Are you able to connect to apns using your certificate? try following command to check that:

$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile server-ca-cert.pem

$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile server-ca-cert.pem

如果命令终止,您将无法连接.如果它继续运行并让您输入套接字,则您已成功连接.

If the command terminates, you are not able to connect. If it continues running and lets you type into the socket, you have connected successfully.

这篇关于在 LINUX w 下使用 PHP 从推送通知创建 .pem 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆