gpt4 book ai didi

php - PHP 的 cURL 命令行

转载 作者:太空宇宙 更新时间:2023-11-03 13:29:20 25 4
gpt4 key购买 nike

我必须从 PHP 向带有自签名证书的安全 https 服务器发出请求。我在 cURL 中有一个可用的命令行,但在将其转换为正确且可用的 PHP 选项时遇到很多问题。

工作的 cURL 命令是这样的:

curl --cacert cert.pem
--key cert.key
--cert cert.crt
--header 'content-type: text/xml'
-X POST
--data @ftit-request.xml https://serverip/dip/DipWebservice > outputfile

谁能给我一些关于如何在 PHP 中正确使用它的提示?

最佳答案

http://php.net/manual/en/book.curl.php

curl_setopt($ch, CURLOPT_VERBOSE, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1');
curl_setopt($ch, CURLOPT_CAINFO, getcwd().'/cert/ca.crt');
curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/mycert.pem');
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'password');

关于php - PHP 的 cURL 命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7677994/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com