简体   繁体   English

iPhone推送通知无法连接到SSL服务器

[英]iPhone Push Notification Unable to Connect to the SSL Server

I followed the instructions at: 我按照以下说明操作:

How To Build An Apple Push Notification Provider Server When I run the php script on my MacOSX or on Windows using Parallel desktop, the script works. 如何构建Apple推送通知提供程序服务器当我在MacOSX或Windows上使用Parallel桌面运行php脚本时,脚本可以正常工作。 But as soon as I run it on my hosting I get the message: 但是只要我在我的托管上运行它,我就收到消息:

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in provider.php on line 23
Failed to connect 110 Connection timed out 

Does this have to do with the certificates? 这与证书有关吗? If so how can I make a certificate that could work on the computer where my hosting is located. 如果是这样,我如何制作可以在我的主机所在的计算机上运行的证书。

Your hosting provider probably does not allow outbound connections to ports 2195 and 2196. Most shared hosting providers do not have those ports open. 您的托管服务提供商可能不允许到端口2195和2196的出站连接。大多数共享主机提供商没有打开这些端口。 You might need to get a VPS or you can also try UrbanAirship which provides Apple Notification Service integration and is free for a certain limit per month. 您可能需要获得VPS,或者您也可以尝试提供Apple Notification Service集成的UrbanAirship,并且每月可以免费获得一定的限制。

Yes you need a certificate. 是的,你需要证书。 THis is explained in the Apple docs. 这在Apple文档中有解释。 One catch, you will probably need to convert the cert to .pem format. 一个问题是,您可能需要将证书转换为.pem格式。 The .pem cert needs to include both the certificate and the RSA private key. .pem证书需要包含证书和RSA私钥。

Here is a good site to read: http://www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/ 这是一个很好的网站: http//www.macoscoders.com/2009/05/17/iphone-apple-push-notification-service-apns/

My pem looks like: 我的pem看起来像:

Bag Attributes
    friendlyName: Apple Development Push Services: <my data>
    localKeyID: <my local key in hexascii> 
subject=/UID=com.my.push.sandbox1/CN=Apple Development Push Services: <my data>/C=US
issuer=/C=US/O=Apple Inc./OU=Apple Worldwide Developer Relations/CN=Apple Worldwide Developer Relations Certification Authority
-----BEGIN CERTIFICATE-----
<my certificate data omitted>
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
<my key data omitted>
-----END RSA PRIVATE KEY-----

I found the simplest and cheapest solution was to request a dedicated IP from your hosting company. 我发现最简单和最便宜的解决方案是从您的托管公司请求专用IP。 At Blue Host it was $2.50 a month. 在Blue Host,每月2.50美元。 With this dedicated IP, they were willing to open ports 2195 and 2196. 有了这个专用IP,他们愿意打开2195和2196端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM