是否可以使用附加了..pfx证书的guzzle6创建POST请求?
文档只提到pem格式:http://docs.guzzlephp.org/en/stable/request-options.html#cert。
发布于 2017-12-14 08:55:14
虽然http://docs.guzzlephp.org/en/stable/request-options.html#cert的文档没有提到这一点,但似乎也可以在口香糖中使用pfx格式。
发布于 2021-10-05 23:12:05
PFX证书用于“相互身份验证”,也就是说,PFX是使用本地私钥和远程公共证书生成的。
若要生成PFX密钥,请运行:
openssl pkcs12 -inkey your_privkey.pem -in remote_pub.cert -export -out mixed.pfx若要使用PFX证书发出请求,您可以:
$api = new \GuzzleHttp\Client([
'base_uri' => $baseUrl,
'cert' => 'path/to/mixed.pfx',
'curl' => [CURLOPT_SSLCERTTYPE => 'P12'], // to define it's a PFX key
]);发布于 2022-06-16 13:26:18
这也适用于drupal 8。
use GuzzleHttp\Client;
// Base URI is used with relative requests
$client = new Client([
'base_uri' => 'https://www.google.com',
'cert' => 'pathtopfxflie/nameof.pfx',
'curl' => [CURLOPT_SSLCERTTYPE => 'P12']]);
$response = $client->request('METHOD', 'api path',['headers' => ['Employer' => 100]]);
//get status code using $response->getStatusCode();
$body = $response->getBody();
$arr_body = json_decode($body);https://stackoverflow.com/questions/47629072
复制相似问题