服务器续订证书后,与WSDL服务的PHP安全连接中断

时间:2016-12-16 01:14:34

标签: php security centos wsdl tls1.2

新证书是" Symantec Class 3 EV SSL CA - G3"。客户有CentOS。无法控制服务器,它是第三方。当在Firefox和Chrome中加载WDSL https地址时,两个浏览器都会显示"安全连接",没问题。

WSDL地址为https://palena.sii.cl/DTEWS/CrSeed.jws?WSDL

测试代码:

$success = false;
$attempts = 0;

while (($success === false) && ($attempts < 10)) {
    $attempts ++;
    echo 'Attempt ' . $attempts . '<br>';

    try {
        $wsdl = 'https://palena.sii.cl/DTEWS/CrSeed.jws?WSDL';
        $entity_loader_status_old = libxml_disable_entity_loader(false);
        $SoapClient = new SoapClient($wsdl);
        $seed = $SoapClient -> getSeed();
        libxml_disable_entity_loader($entity_loader_status_old);
        $success = true;
    } catch (Exception $Exception) {
        echo $Exception -> getMessage() . '<br>';
    }
}

if ($success === true) {
    echo 'SUCCESS';
} else {
    echo 'ERROR';
}

默认情况下连接是安全的,因为PHP版本是5.6.22(大于5.5.x)。

1 个答案:

答案 0 :(得分:0)

可能重复:OpenSSL: unable to verify the first certificate for Experian URL

要解决创建cafile.pem并连接所需的Symantec证书(主要中间人和根证书),如上面可能的重复问题链接所示(请参阅 spuder 的答案)。

要创建的引自 spuder cafile.pem

-----BEGIN CERTIFICATE----- 
(Your Primary SSL certificate: your_domain_name.crt) 
-----END CERTIFICATE----- 
-----BEGIN CERTIFICATE----- 
(Your Intermediate certificate: DigiCertCA.crt) 
-----END CERTIFICATE----- 
-----BEGIN CERTIFICATE----- 
(Your Root certificate: TrustedRoot.crt) 
-----END CERTIFICATE-----

然后在PHP中使用下一个$options创建SoapClient对象:

$options = [
    'stream_context' => stream_context_create([
        'ssl' => [
            'cafile' => __DIR__ . '/cafile.pem',
        ],
    ]),
];

$SoapClient = new SoapClient($wsdl, $options);