如何使用 SHA2 和 TLS 1.2 版发送 soap 请求

How to send soap request with SHA2 and TLS version 1.2

我只想使用 SHA2TLS1.2 向 soap 服务器发送 Soap 请求,但在尝试创建 soap 客户端时显示以下错误

错误

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://example.com/wsdl' : failed to load external entity "https://example.com/wsdl"

代码

$url = 'https://example.com/wsdl';

$client = new SoapClient(
            $url,
            array(
              'ssl_method' => SOAP_SSL_METHOD_TLS,
              'cache_wsdl'    => WSDL_CACHE_NONE,
              'stream_context'=> stream_context_create(
                array(
                  'ssl'=> array(
                    'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT,
                    'ciphers' => 'SHA2',
                    'verify_peer'=>false,
                    'verify_peer_name'=>false, 
                    'allow_self_signed' => true //can fiddle with this one.
                  )
                )
              )
            )
          );

你没有要放在 ssl 数组中的证书吗?

'cafile' => $certFile

已通过在ciphars中添加SHA256解决。实际上SHA2有4种哈希函数:SHA224SHA256SHA384SHA512.

变化

'ciphers' => 'SHA256',

回答自己的问题对我来说有点奇怪,但它可以帮助其他开发者。