我有一個cURL請求在通過我的PHP 5.4.48應用運行時失敗。有趣的是,它直接通過控制檯或Postman運行時正確執行。cURL不受支持的SSL協議
我連接的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 '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)
我一直在排除故障自上週以來這個問題。有任何想法嗎???
是類似的問題? http://stackoverflow.com/questions/21612132/unsupported-protocol-using-curl-in-c –
感謝但不是相同的問題。該海報試圖在沒有支持HTTPS的cURL安裝的情況下發出HTTPS cURL請求。 –
預期結果是什麼? –