在PHP CURL SSL调用中是否真的忽略了我的密钥?
我正在使用TestApi使用PEM和密钥文件检查SSL连接。 但是,如果我编辑我的私钥,似乎我仍然可以得到标题。 它真的应该这样做吗?我从来没有收到过关于密钥的错误。然而,当认证不正确时,我确实会出错 我总是得到一份工作 HTTP/1.1 200 OK内容类型:text/xml;charset=UTF-8内容长度:5983日期:2016年8月18日星期四21:10:33 GMT服务器:服务器服务器总线RP接口版本:4.0.0 然后是在PHP CURL SSL调用中是否真的忽略了我的密钥?,php,ssl,curl,Php,Ssl,Curl,我正在使用TestApi使用PEM和密钥文件检查SSL连接。 但是,如果我编辑我的私钥,似乎我仍然可以得到标题。 它真的应该这样做吗?我从来没有收到过关于密钥的错误。然而,当认证不正确时,我确实会出错 我总是得到一份工作 HTTP/1.1 200 OK内容类型:text/xml;charset=UTF-8内容长度:5983日期:2016年8月18日星期四21:10:33 GMT服务器:服务器服务器总线RP接口版本:4.0.0 然后是htmlentities中的sh*t文本 $url = "htt
htmlentities
中的sh*t文本
$url = "https://mylink?wsdl";
// cert file/pass (same as pfx above but converted to pem and key)
$cert_file = "myPemfile.pem";
$cert_password = "myKeyfile.key"; // I've intentionally set the wrong key... but God knows why it still works
// server cert which we trust (this is needed when using VERIFYPEER below)
$cert_server = "serverCA.pem";
$ch = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => true, //return output
CURLOPT_HEADER => true, // just to see header response
CURLOPT_FOLLOWLOCATION => true, // cant figure this out yet (probably means internal redirect within $url)
CURLOPT_SSL_VERIFYHOST => 2, //ok
CURLOPT_SSL_VERIFYPEER => true, // yes
CURLOPT_CAINFO => $cert_server, // set it
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)', // ? seems this is needed
CURLOPT_VERBOSE => false, // change to true/false if you want/(dont want) verbose
CURLOPT_URL => $url , //set
CURLOPT_SSLCERT => $cert_file, //set
//CURLOPT_SSLCERTTYPE => 'PEM', // well.. default is PEM anyway
CURLOPT_SSLKEY => $cert_password, //set
);
curl_setopt_array($ch , $options);
$output = curl_exec($ch);
if(!$output)
{
echo "Curl Error : " . curl_error($ch);
}
else
{
echo "<br /> db: output unparsed :<br />" . $output . "<br /> db: DONE <br /><br />";
echo htmlentities($output);
}
$url=”https://mylink?wsdl";
//证书文件/通行证(与上述pfx相同,但转换为pem和密钥)
$cert\u file=“myPemfile.pem”;
$cert\u password=“myKeyfile.key”;//我故意设置了错误的键。。。但上帝知道为什么它仍然有效
//我们信任的服务器证书(使用下面的VERIFYPEER时需要此证书)
$cert\u server=“serverCA.pem”;
$ch=curl_init();
$options=数组(
CURLOPT_RETURNTRANSFER=>true,//返回输出
CURLOPT_HEADER=>true,//只需查看HEADER响应
CURLOPT_FOLLOWLOCATION=>true,//目前还不能解决这个问题(可能意味着$url内的内部重定向)
CURLOPT_SSL_VERIFYHOST=>2,//确定
CURLOPT_SSL_VERIFYPEER=>true,//是
CURLOPT_CAINFO=>$cert_server,//设置它
CURLOPT_USERAGENT=>“Mozilla/4.0(兼容;MSIE 5.01;Windows NT 5.0)”,//?似乎需要这样做
CURLOPT_VERBOSE=>false,//如果希望/(不希望)详细,请更改为true/false
CURLOPT_URL=>$URL,//设置
CURLOPT\u SSLCERT=>$cert\u文件,//设置
//CURLOPT_SSLCERTTYPE=>PEM',//well..默认值仍然是PEM
CURLOPT\u SSLKEY=>$cert\u密码,//设置
);
curl_setopt_数组($ch$options);
$output=curl\u exec($ch);
如果(!$输出)
{
echo“Curl Error:.Curl_Error($ch);
}
其他的
{
echo“
db:output unparsed:
.”$output.“
db:DONE
”;
回音频率(输出);
}
有几种可能适合您的描述:
- 服务器根本不需要客户端证书。在这种情况下,您提供的客户端证书和密钥并不重要,因为它无论如何都不会被使用
- 真正的密钥已经包含在您为证书提供的PEM文件中
----开始私钥------之间的部分-----结束私钥------
。哦,好的,那么前缀和后缀私钥
需要存在吗?@niCkcAMel:此前缀和后缀属于密钥的PEM编码,应该与密钥一起删除。我错过了您的“…包括…”。对不起,我的错