doubaisui2526 2013-12-24 13:35
浏览 1924

卷曲错误:错误: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" . "
";

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);

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.

  • 写回答

2条回答 默认 最新

  • douyong8801 2014-10-15 08:03
    关注

    I got same Error I have resolved it by changing

    sslVersion = 3 
    

    updated To

    sslVersion = 'all'
    

    It works for me

    In your case I think you need to change

    curl_setopt($ch, CURLOPT_SSLVERSION,3);
    

    to

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

    It should work

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘