APNS ssl://gateway.sandbox.push.apple.com:2195 连接失败

发布于 2024-11-15 12:26:31 字数 1139 浏览 2 评论 0原文

我尝试制作一个推送通知服务器。 我通过 telnet 连接到 ssl://gateway.sandbox.push.apple.com:2195 。

telnet gateway.sandbox.push.apple.com 2195
Trying 17.172.232.229...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.

我的 *.pem 没问题(我在另一台服务器上使用它)。 我在其他服务器上使用相同的项目,它可以在那里工作,但其他服务器上的克隆却不能。

我收到这些错误:

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094415:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate expired in /var/www/try.php on line 69

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /var/www/try.php on line 69

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

证书未过期,它在其他服务器上有效并且日期相同。

有人知道错误可能是什么吗?

我从事

Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g

编辑工作: 看来,在不同的服务器上使用相同的证书是行不通的。也许这被苹果服务器阻止了。

i try to make a push-notification server.
I get connection to ssl://gateway.sandbox.push.apple.com:2195 with telnet.

telnet gateway.sandbox.push.apple.com 2195
Trying 17.172.232.229...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.

my *.pem is ok (I use it on another server).
I use the SAME project on an other Server and it works there but the clone on an other Server doesn't.

I get these Errors:

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094415:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate expired in /var/www/try.php on line 69

Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /var/www/try.php on line 69

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

The certificate is NOT expired, it works on the other Server and the date is the same.

Does someone has a clue what the mistake could be?

I work on

Apache/2.2.9 (Debian) PHP/5.2.17-0.dotdeb.0 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g

EDIT:
It seems, that using the same certificate on different servers doesn't work. Maybe this is blocked by Apples servers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

墨落画卷 2024-11-22 12:26:31

我使用 apn_on_rails 来实现此目的,但我认为只要您使用 pem 文件。我通过重新下载证书和中间证书、使用以下说明重新生成推送通知 pem 文件来解决此问题:

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

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

I use apn_on_rails for this, but I think it will work for you as long as you are using a pem file. I fixed this by re-downloading the certificate and intermediate certificate, regenerating the push notification pem file using these instructions:

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
ˇ宁静的妩媚 2024-11-22 12:26:31

这种错误发生在两种情况下:

  1. 2195端口被阻塞时。
  2. .pem 文件未正确制作时(如我的情况)。

尝试这两点。您肯定不会收到任何错误。

This kind of error occur in two situation:

  1. When the 2195 port is block.
  2. When the .pem file is not made correctly (as in my case).

Try these two points. You will surely not get any error.

梨涡少年 2024-11-22 12:26:31

我遇到了同样的问题,但我的解决方案是需要绝对路径的 pem 证书

  1. 使用私钥的绝对路径而不是相对路径。
  2. 确保允许 php 用户(或 Web 服务器用户,具体取决于.. www-data、apache、nginx、www...)读取它(chown、chmod)。

来自此处

I had the same problem but the solution in my case was that pem certificate that required absolute path

  1. Use the absolute path for the private key instead of relative path.
  2. Make sure the php user (or webserver user, depending.. www-data, apache, nginx, www...) is allowed to read it (chown, chmod).

from here

对你的占有欲 2024-11-22 12:26:31

从互联网上随机发现的一些内容可能会有所帮助:

这可能是证书问题。尝试使用流选项allow_self_signed 和verify_peer 来检查这一点。

尝试明确使用 sslv2:// 或 sslv3:// ?

“/dev/urandom”的权限问题

Some random finding from the internet which could help:

It may be a certificate problem. Try the stream options allow_self_signed and verify_peer to check that.

Try to use explicitely sslv2:// or sslv3:// ?

Permission problem on "/dev/urandom"

岁月静好 2024-11-22 12:26:31

也许你的 ISP 阻止了端口 2195 和 2196。我也遇到了同样的问题,要求他们打开它,这对我有用。

Maybe your ISP block ports 2195 and 2196. I had the same problem, asked them to open it and that worked for me.

吝吻 2024-11-22 12:26:31

你提到:

我在其他服务器上使用相同的项目,它可以在那里工作,但其他服务器上的克隆则不能。

我发现 .pem 证书无法转移。以下是我让一个在一台 OS X 机器上运行的应用程序在另一台机器上运行的步骤(不知道如何为非 Apple 机器执行此操作):

  1. 复制第一台服务器的 .p12 文件(证书和配套私有文件) -钥匙)。
  2. 将该 .p12 文件复制到您的钥匙串中。它将成为那里的证书。
  3. 将该证书(带有配套私钥)导出到 .p12 文件。
  4. 使用 openssl 将新的 .p12 文件转换为新的 .pem 文件
  5. 您现在可以在新服务器上的 openssl 命令中使用新的 .pem 文件。

希望这有帮助

You mention:

I use the SAME project on an other Server and it works there but the clone on an other Server doesn't.

I've found that .pem certificates don't transfer. Here are the steps I followed to get an app that works on one OS X machine to work on another (don't know how to do it for non-Apple machines):

  1. Copy over the first Server's .p12 file (Certificate and companion private-key).
  2. Copy that .p12 file into your keychain. It will become a certificate there.
  3. Export that certificate (with companion private key) to a new .p12 file.
  4. Use openssl to convert that new .p12 file into a new .pem file
  5. You can now use the new .pem file in your openssl command on the new server.

Hope this is helpful

伪装你 2024-11-22 12:26:31

我的 Linux 机器上也有类似的问题。对我来说,这是 SELinux 问题。

因此,在 /etc/selinux/config 文件中,将 SELINUX=enforcing 设置为 SELINUX=disabled。并重新启动。就是这样。

I had a similar issue on my Linux box. To me, it was the SELinux issue.

So in your /etc/selinux/config file, set the SELINUX=enforcing to SELINUX=disabled. And restart. Thats it.

再见回来 2024-11-22 12:26:31

尝试...
telnet gateway.sandbox.push.apple.com:2195
而不是...
telnet gateway.sandbox.push.apple.com 2195

try...
telnet gateway.sandbox.push.apple.com:2195
instead of ...
telnet gateway.sandbox.push.apple.com 2195

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文