gpt4 book ai didi

php - cURL 不支持的 SSL 协议(protocol)

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

我有一个 cURL 请求在通过我的 PHP 5.4.48 应用程序运行时失败了。有趣的是,当直接通过控制台或通过 Postman 运行它时,它会正确执行。

我正在连接的 API 需要 TLSv1.2 连接,我在我的应用程序中指定了该连接。

这是我在 PHP 应用程序中的简单请求:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://dev-dataconnect.givex.com:50104');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);

curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain;charset=UTF-8'));
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
// curl_setopt($ch, CURLOPT_SSLVERSION, 'CURL_SSLVERSION_TLSv1_2'); // specifying value by name was of no help
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLS_RSA_WITH_AES_256_CBC_SHA256');

curl_exec($ch);

一个原始的 cURL 请求看起来像这样(注意它从控制台中成功触发)

curl 'https://dev-dataconnect.givex.com:50104/' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data-binary $'{"method":"dc_909","id":"confidential","jsonrpc":"2.0","params":["en","confidential","29530","confidential"]}\n' --compressed

另请注意,我不需要为成功的握手指定 SSL 版本

这是运行 curl -v ' https://dev-dataconnect.givex.com:50104/ 的打印输出'

* Connected to dev-dataconnect.givex.com (72.15.49.106) port 50104 (#0)
* TLS 1.2 connection using TLS_RSA_WITH_AES_256_CBC_SHA256
* Server certificate: *.givex.com
* Server certificate: Trustwave Organization Validation SHA256 CA, Level 1
* Server certificate: SecureTrust CA
> GET / HTTP/1.1
> Host: dev-dataconnect.givex.com:50104
> User-Agent: curl/7.43.0
> Accept: */*

我在跑

 - PHP 5.4.48
- curl 7.43.0 (within both my MAMP and my Mac environments)
- OpenSSL/0.9.8zd (within both my MAMP and my Mac environments)

自上周以来,我一直在解决这个问题。有什么想法吗???

最佳答案

  • OpenSSL/0.9.8zd (within both my MAMP and my Mac environments)

...

The API I'm connecting to expects a TLSv1.2 connection, which I am specifying in my app.

OpenSSL 0.9.8 不支持 TLS 1.2。仅在 OpenSSL 1.0.1 中添加了支持。

关于php - cURL 不支持的 SSL 协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34914065/

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