Home > Backend Development > PHP Tutorial > 使用PHP SoapClient 处理自建证书的https服务

使用PHP SoapClient 处理自建证书的https服务

WBOY
Release: 2016-06-21 08:45:48
Original
1322 people have browsed it

使用PHP的SoapClient处理认证过的https webservice是完全没有问题的。但是如果遇到一些不去认证https而是用自建的证书来做https的时候就会有问题,一般会报“Could not connect to host.”错误。


解决方式之一就是试SoapClient忽略https的ssl认证,直接跳过认证的环节,直接贴代码吧

$context = stream_context_create( array (    'ssl' => array (        'verify_peer' => false,        'allow_self_signed' => true    ),));$options['stream_context'] = $context;$client = new SoapClient($url, $options);
Copy after login

verify_peer:指定是否验证ssl,默认为true

allow_self_signed:是否允许自建证书的https服务,默认为false


贴上官方的文档:http://php.net/manual/en/context.ssl.php


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template