PHP不使用SSL证书 [英] PHP not using SSL certificate

查看:273
本文介绍了PHP不使用SSL证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个feedback.php文件从我的数据库中删除非活动设备。
我有剧本的工作,现在code:

I am trying to use a feedback.php file to remove inactive devices from my database. I have the script working for now code:

<?php
# -*- coding: utf-8 -*-
##
##     Copyright (c) 2010 Benjamin Ortuzar Seconde <bortuzar@gmail.com>
##
##     This file is part of APNS.
##
##     APNS is free software: you can redistribute it and/or modify
##     it under the terms of the GNU Lesser General Public License as
##     published by the Free Software Foundation, either version 3 of
##     the License, or (at your option) any later version.
##
##     APNS is distributed in the hope that it will be useful,
##     but WITHOUT ANY WARRANTY; without even the implied warranty of
##     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
##     GNU General Public License for more details.
##
##     You should have received a copy of the GNU General Public License
##     along with APNS.  If not, see <http://www.gnu.org/licenses/>.
##
##
## $Id: processFeedback.php 168 2010-08-28 01:24:04Z Benjamin Ortuzar Seconde $
##

require_once('config.php');
require_once('classes/DataService.php');
require_once('classes/Apns.php');
echo "<br/>Started processing Feedback";
error_reporting(E_ALL);
ini_set( 'display_errors','1'); 

//get the certificates
$certificates = DataService::singleton()->getCertificates();

foreach ($certificates as $certificate) {

    //only process apps that have a certificate associated to it.
    if($certificate->KeyCertFile == ''){

        echo "<br/>Certfile not set for App: [{$certificate->CertificateName}]";
        continue;
    }
    //var_dump($certificate);
    //connect to feedback server
    $certificatePath = $certificateFolder . '/' . $certificate->KeyCertFile;

    $server = DataService::singleton()->getCertificateServer($certificate->CertificateId, 3);
    $apns = new apns('feedback.sandbox.push.apple.com:2196', $certificatePath, $certificate->Passphrase);


    //get tokens
    $feedbackTokens = $apns->getFeedbackTokens();

    //close connection
    unset($apns);

    //print the number of tokens to check for
    $countTotal = count($feedbackTokens);
    echo "<br/>There are [{$countTotal}] tokens notified by feedback";

    //loop trough the tokens
    foreach ($feedbackTokens as $feedbackToken) {

        //only DeActivate devices that where updated before they where removed. Otherwise the user could of installed the app again.
        DataService::singleton()->setDeviceInactive($feedbackToken['devtoken'], $app->AppId, $feedbackToken['timestamp']);
    }
}
echo "<br/>Completed processing Feedback";
?>

(完整的源:的https://github.com/bortuzar/PHP-Mysql---Apple-Push-Notification-Server/blob/master)

不过我有一个连接到服务器的一个问题。提供推送通知,做工精细,但这种反馈脚本不起作用。
它不使用证书,我输入这是发生了什么:

However I have a problem with connecting to the server. Delivering push notifications work fine but this feedback script doesn't work. It's not using the certificate that I input this is what happens:

<br/>Started processing Feedback<br/>Opening connection to: feedback.sandbox.push.apple.com:2196<br/>Clossing connection to: feedback.sandbox.push.apple.com:2196<br/>There are [0] tokens notified by feedback<br/>Opening connection to: feedback.sandbox.push.apple.com:2196<br/>Clossing connection to: feedback.sandbox.push.apple.com:2196<br/>There are [0] tokens notified by feedback<br/>Completed processing Feedback

不过,这回帖数令牌。当我刚刚连接到一个随机主机它显示了相同的:

But, It replies 0 tokens. And when I just connect to a random host it shows the same:

<br/>Started processing Feedback<br/>Opening connection to: localhost:80<br/>Clossing connection to: localhost:80<br/>There are [0] tokens notified by feedback<br/>Opening connection to: localhost:80<br/>Clossing connection to: localhost:80<br/>There are [0] tokens notified by feedback<br/>Completed processing Feedback

获得答复需要一段时间。
我想这事做的证书,如果我没有弄错还是我失去了一些PHP包括?

Getting a reply takes a while to. I guess this has something to do with the certificate if I am not mistaking or am I missing some sort of PHP include?

推荐答案

如果我从你的<一个记错href=\"http://stackoverflow.com/questions/14606970/php-trying-to-get-property-of-non-object/14608370#14608370\">earlier问题你的$服务器变量是NULL。这意味着,我认为真正的问题在于行

If I recall correctly from your earlier problem your $server variable was NULL. This implies to me that the real problem lies in the line

$server = DataService::singleton()->getCertificateServer($certificate->CertificateId, 3);

如果一切是犹太使用证书,这应该已经返回一个有效的服务器。但事实并非如此 - 你暂时工作围绕硬编码 $服务器中的下一行变量:

If everything was kosher with your certificate, this should have returned a valid server. But it didn't - which you temporarily worked around by hard coding the $server variable in the next line:

$apns = new apns('feedback.sandbox.push.apple.com:2196', $certificatePath, $certificate->Passphrase);

在换句话说 - 你是对怀疑有问题与您的证书

In other words - you are right to suspect there is a problem with your certificate.

您可能会发现在这个特定的信息<一个href=\"http://stackoverflow.com/questions/1635111/apple-push-notification-service-certificate-install-server-side\">earlier回答有用的解决这个问题。

You might find the information given at this earlier answer useful to solve that issue.

这篇关于PHP不使用SSL证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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