向明确给定的 IP 发出请求,但为了 SSL 验证的目的使用明确给定的主机名?

Make request to explicitly given IP, but use explicitly given hostname for the purpose of SSL verification?

有没有办法同时告诉GuzzleHttp\Client

由于超出这个问题范围的原因,我不能简单地传递“https://some.host.name/uri" as the request URL. I must pass https://<some-numerical-IP>/uri”并设置Host header .但是,当我这样做时,Guzzle 忽略 Host header 以进行 SSL 主机和对等验证,并尝试使用失败的数字 IP 地址。

我如何获取 WhatIWant™?

尽管评论中有所有 "XY problem" 的讨论,但事实证明这是 100% 纯正的 "Y problem",这里是 the solution:

$client = new GuzzleHttp\Client([
    'curl' => [CURLOPT_RESOLVE => ['fakedomain.dev:80:127.0.0.1']],
]);