PHP脚本与cURL在一个服务器上工作...在其他服务器上不工作 [英] PHP Script with cURL works on one server...does not work on other server
问题描述
感谢您提供的所有帮助。这是我的问题:
Thanks in advance for all your help. Here is my issue:
我有一个双节点服务器配置,两个服务器(应该)完全相同。两者都安装了PHP。我能够在一个节点上完美运行我的cURL PHP脚本,但不能在另一个节点上运行。下面是两个实例的详细(调试)输出:
I have a dual node server configuration with two servers that (should) be exactly identical. Both have PHP installed. I am able to run my cURL PHP script flawlessly on one node, but not on the other. Here are the verbose (debug) outputs from both instances:
已知工作(节点2):
stderr=* About to connect() to company.sharepoint.com port 443
* Trying 191.234.148.26... * connected
* Connected to company.sharepoint.com (191.234.148.26) port 443
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using AES256-SHA
* Server certificate:
* subject: /C=US/ST=WA/L=Redmond/O=Microsoft/CN=*.sharepoint.com
* start date: 2014-04-14 22:01:07 GMT
* expire date: 2016-04-13 22:01:07 GMT
* subjectAltName: company.sharepoint.com matched
* issuer: /DC=com/DC=microsoft/DC=corp/DC=redmond/CN=MSIT Machine Auth CA 2
* SSL certificate verify ok.
> POST /_forms/default.aspx?wa=wsignin1.0 HTTP/1.1
Host: company.sharepoint.com
Accept: */*
Content-Length: 1021
Content-Type: application/x-www-form-urlencoded
错误(节点1):
* About to connect() to company.sharepoint.com port 443
* Trying 191.234.148.26... * connected
* Connected to company.sharepoint.com (191.234.148.26) port 443
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* Unknown SSL protocol error in connection to company.sharepoint.com:443
* Closing connection #0
PHP Fatal error: Uncaught exception 'Exception' with message 'Curl error: Unknown SSL protocol error in connection to company.sharepoint.com:443 ' in /opt/CLA2/sharepoint/sharepoint.php:391
Stack trace:
#0 /opt/CLA2/sharepoint/sharepoint.php(39): getAuthCookies('t=EwDwAk6hBwAUG...', 'https://paychex...', '1')
#1 {main}
thrown in /opt/CLA2/sharepoint/sharepoint.php on line 391
有任何建议吗?我很困惑为什么两个假定相同的节点会有不同的结果。
Any suggestions? I'm baffled why two supposedly identical nodes would have different results.
再次感谢您的帮助!
推荐答案
未知SSL协议错误
表示SSL协商失败。这可能是由于不兼容的密码或SSL版本。您可以尝试显式设置密码和版本来解决此问题。
The Unknown SSL protocol error
means the SSL negotiation failed. This is possibly due to incompatible ciphers or SSL version. You could try explicitly setting the cipher and version to work around this.
使用 Qualys SSL测试,支持的密码为:
TLS_RSA_WITH_AES_256_CBC_SHA
TLS_RSA_WITH_AES_128_CBC_SHA
TLS_RSA_WITH_3DES_EDE_CBC_SHA
TLS_RSA_WITH_RC4_128_SHA
TLS_RSA_WITH_RC4_128_MD5
,支持的版本为 SSLv3
和 TLSv1
。
所以你可以做
curl_setopt($handle, CURLOPT_SSLVERSION, 3);
curl_setopt($handle, CURLOPT_SSL_CIPHER, 'TLS_RSA_WITH_AES_256_CBC_SHA:TLS_RSA_WITH_AES_128_CBC_SHA:TLS_RSA_WITH_3DES_EDE_CBC_SHA');
这篇关于PHP脚本与cURL在一个服务器上工作...在其他服务器上不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!