【问题标题】:When using Docker, SOAP is unable to resolve SSL requests使用 Docker 时,SOAP 无法解析 SSL 请求
【发布时间】:2019-02-08 07:45:35
【问题描述】:

我正在尝试通过 Docker 应用程序中的 SOAP 连接到 SSL 主机。

尝试这样做时,我必须在传输级别禁用 SSL 以使其正常工作。我正在使用这样的代码:

$context = stream_context_create([
    'ssl' => [
        // set some SSL/TLS specific options
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);

$client  = new SoapClient(null, [
    'location' => 'https://...',
    'uri' => '...', 
    'stream_context' => $context
]);

这也是most upvoted answer on this question.

所以,我想要实现的是在没有这种 hack 的情况下让连接运行。

如果我忽略它,我会收到以下异常:

( ! ) Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.myhost.tld/gateway/Method?wsdl' : failed to load external entity "https://api.myhost.tld/gateway/Method?wsdl" in /var/www/html/app/code/local/Vendor/MyHost/Model/Method.php on line 31

【问题讨论】:

    标签: php docker soap


    【解决方案1】:

    您需要为您的域 api.myhost.tld 提供受信任的证书才能使其正确。因此,您可以购买“官方”SSL 证书并将其附加到您的 SOAP 网络服务器或创建自签名证书并将该证书添加到您的 docker 映像中,如下所述:How do I add a CA root certificate inside a docker image?

    【讨论】:

    • 我怎样才能获得第 3 方 SSL 证书的访问权限? 'api.myhost.tld' 实际上不是我的主机,它是我无法进一步访问的外国主机。
    • 因此,如果该主机使用自签名证书,只需使用其中一种建议的方法导出该证书:support.google.com/gsa/answer/6345106?hl=en 并将该证书添加为受 CA 信任,就像我在答案中提供的链接中一样
    • 完成了这项工作! :)
    猜你喜欢
    • 2017-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 1970-01-01
    • 1970-01-01
    • 2017-11-08
    • 2018-06-03
    相关资源
    最近更新 更多