使用PHP SoapClient 处理自建证书的https服务
摘要 使用PHP soap处理自建证书https服务的认证问题 “Could not connect to host.”解决方法
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 );
verify_peer:指定是否验证ssl,默认为true
allow_self_signed:是否允许自建证书的https服务,默认为false