POST 使用带有 pfx 证书的 guzzle6 请求
POST request using guzzle6 with pfx-certificate
是否可以使用附有 .pfx 证书的 guzzle6 创建 POST 请求?
文档只提到 pem 格式:http://docs.guzzlephp.org/en/stable/request-options.html#cert
虽然 http://docs.guzzlephp.org/en/stable/request-options.html#cert 的文档没有提及,但似乎也可以将 pfx 格式与 guzzle 一起使用。
PFX 证书用于“相互身份验证”,也就是说,PFX 是使用您的本地私钥和远程 public 证书生成的。
要生成 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
]);
是否可以使用附有 .pfx 证书的 guzzle6 创建 POST 请求?
文档只提到 pem 格式:http://docs.guzzlephp.org/en/stable/request-options.html#cert
虽然 http://docs.guzzlephp.org/en/stable/request-options.html#cert 的文档没有提及,但似乎也可以将 pfx 格式与 guzzle 一起使用。
PFX 证书用于“相互身份验证”,也就是说,PFX 是使用您的本地私钥和远程 public 证书生成的。
要生成 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
]);