6

我在 IOS 设备上遇到推送通知的 APNS php 代码问题,我有两个独立的开发和生产连接。

  1. 我已经通过添加 .pem 文件证书和 Passphares 来配置我的服务器上的开发连接,它的工作完美,我也收到了通知。看看我的开发配置:

网址:'ssl://gateway.sandbox.push.apple.com:2195'

$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
    'APNS_Dev_ISAS.pem'
);
$myNewLogger = new MyNewLogger();
$push->setLogger($myNewLogger);

// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('1234567');

$push->setRootCertificationAuthority('APNS_Dev_ISAS.pem');
$push->connect();

问题:

  1. 比我通过添加以下参数配置生产连接但我收到连接错误:

网址:ssl://gateway.push.apple.com:2195

$push = new ApnsPHP_Push(
    ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION,
    'APNS_PROD_ISAS.pem'
);
$myNewLogger = new MyNewLogger();
$push->setLogger($myNewLogger);

// Set the Provider Certificate passphrase
$push->setProviderCertificatePassphrase('12345678');

$push->setRootCertificationAuthority('APNS_PROD_ISAS.pem');
$push->connect();

连接错误: 信息:尝试 ssl://gateway.push.apple.com:2195...错误:无法连接到“ssl://gateway.push.apple.com:2195”:(0)信息:重试连接(1/3)...信息:尝试 ssl://gateway.push.apple.com:2195...错误:无法连接到 'ssl://gateway.push.apple.com:2195 ':(0)信息:重试连接(2/3)...信息:正在尝试 ssl://gateway.push.apple.com:2195...错误:无法连接到 'ssl://gateway。 push.apple.com:2195': (0) INFO: Retry to connect (3/3)... INFO: Trying ssl://gateway.push.apple.com:2195...ERROR: Unable to connect to 'ssl://gateway.push.apple.com:2195': (0)

我用谷歌搜索了这个问题,我找到了一些解决方案,我检查了一切,一切都很好,但没有成功。

  • 我使用了正确的开发和生产路径。
  • 我为两者创建了单独的证书 .pem 文件,并在推送应用程序上测试了证书。证书正确。
  • 端口也很好,并且没有从我的服务器阻塞,因为在开发 url 中使用了相同的端口,并且开发服务器推送通知工作正常。

任何帮助将不胜感激。提前致谢。

4

2 回答 2

6

我为推送通知创建的证书 (.pem) 存在问题。

解决方案: 几天尝试相同的问题后,我发现使用迷你字符密码创建证书可能是 1234,它将非常适合您并成功连接到 IOS 推送通知服务器。

可能这会帮助别人。

谢谢。

于 2015-11-02T04:49:30.553 回答
0

当我执行我的 PHP 脚本时,我遇到了同样的问题。经过一番研究,我评论了这三个密钥对值“cafile”、“CN_match”和“ciphers”。

然后它开始正常工作。我希望这个回复也对其他人有用。

$contextOptions = array(
'ssl' => array(
    'verify_peer' => false, // You could skip all of the trouble by changing this to false, but it's WAY uncool for security reasons.
//    'cafile' => 'NiteVisionWebPushFile.pem',
//    'CN_match' => 'gateway.push.apple.com', // Change this to your certificates Common Name (or just comment this line out if not needed)
  //  'ciphers' => 'HIGH:!SSLv2:!SSLv3',
    'disable_compression' => true,
));
于 2018-02-26T11:44:49.340 回答