Curl错误:错误:1408F10B:SSL例程:SSL3_GET_RECORD:错误的版本号 [英] Curl Error :error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

查看:2331
本文介绍了Curl错误:错误:1408F10B:SSL例程:SSL3_GET_RECORD:错误的版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,它给我Curl错误:错误:1408F10B:SSL例程:SSL3_GET_RECORD:错误的版本号错误。

I have the following code which gives me "Curl Error :error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number" error.

$url='https://mysite/login';

$clientcert  =       "C:\\client.crt"; 
$keyfile     =       "C:\\server.key"; 
$challenge   =       "passphrase"; 
$CAFile      =       "C:\\server.pem";
print "<bR><BR>$challenge<br><br>"; 
print "<bR><BR>$keyfile<br><br>"; 
print "<bR><BR>$clientcert<br><br>"; 
print "<bR><BR>$CAFile<br><br>"; 

$header=array('contentType:application/json','MY-API-Key:34sdSDFSDFxcvxcvxcvEEE11','Content-Type:application/json','Accept: application/json');

$username=base64_encode("uname");
$password=base64_encode("pswd");

$ch = curl_init(); 
if(FALSE==$ch)
  echo "Unable to create Url Object" . "\n";

curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,3);
//curl_setopt($ch, CURLOPT_POSTFIELDS,"$username:$password");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:26.0) Gecko/20100101 Firefox/26.0");       
curl_setopt($ch, CURLOPT_USERPWD,"$username:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLINFO_HEADER_OUT, 1); 
curl_setopt($ch, CURLOPT_SSLCERT, $clientcert); 
curl_setopt($ch, CURLOPT_CAPATH, $CAFile); 
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $challenge); 
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, $challenge); 
curl_setopt($ch, CURLOPT_SSLKEYTYPE, 'PEM'); 
curl_setopt($ch, CURLOPT_SSLKEY, $keyfile); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
//curl_setopt($ch, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0);
  $response = curl_exec($ch);  
 $info=curl_getinfo($ch);

我已经使用与服务器相同的一个密码和sha384算法生成了证书。所以我有私钥,证书(.crt文件)和密码,我在apache和curl脚本中设置。
请建议可能是什么问题。

I have generated the certificate using the one passphrase and sha384 algorithm same as that of server. So I have private key, certificate (.crt file) and passphrase that I have set in apache as well as in the curl script. Please suggest what could be the issue.

推荐答案

我有同样的错误我已经解决了通过改变

I got same Error I have resolved it by changing

sslVersion = 3 

更新至

sslVersion = 'all'

它适用于我

在您的情况下,我认为您需要更改

In your case I think you need to change

curl_setopt($ch, CURLOPT_SSLVERSION,3);

curl_setopt($ch, CURLOPT_SSLVERSION,'all'); 

它应该工作

这篇关于Curl错误:错误:1408F10B:SSL例程:SSL3_GET_RECORD:错误的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆