简体   繁体   English

在PHP中发送多个带有curl的.crt证书

[英]send multiple .crt certificate with curl in php

I want to send two .crt certificates with curl in php. 我想在php中发送两个带有curl的.crt证书。 I am using this code. 我正在使用此代码。

$firstcalldata = "csv file data";
$target_url = www.example.com;
$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_VERBOSE, '1'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_CAINFO,"C:/Users/admin/Desktop/CERT/PSCERT.pem");
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "C:/Users/admin/Desktop/CERT/PSCERT-C.crt");
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $firstcalldata);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:  application/csv'));
$result = curl_exec($ch);
echo $result;
curl_close($ch);`

I am sending also a csv file to $target_url. 我还将csv文件发送到$ target_url。

But all time I am getting 403 - Forbidden: Access is denied. 但是我一直都在403-禁止访问:访问被拒绝。

You're not really saying what you want to accomplish, you're just asking a very weird question with no answer. 您并不是真的在说要达成的目标,只是在问一个非常奇怪的问题而没有答案。 You example doesn't send the .crt at all, it uses it to verify the server's certificate. 您的示例根本不发送.crt,而是使用它来验证服务器的证书。 And CAINFO is meant to point to a file holding a full bundle (like one of those you can get at curl's caextract page ) CAINFO旨在指向一个包含完整捆绑包的文件(例如您可以在curl的caextract页面上找到的捆绑包之一)

But you disable both VERIFYPEER and VERIFYHOST so you don't actually need any CA cert!? 但是您同时禁用了VERIFYPEER和VERIFYHOST,因此您实际上不需要任何CA证书!

What exactly do you want to do? 您到底想做什么? Note also how getting a 403 back means that you already communicate fine over the TLS layer. 还请注意,取回403意味着您已经在TLS层上进行了良好的通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM