1. <i id='1lsak'><tr id='1lsak'><dt id='1lsak'><q id='1lsak'><span id='1lsak'><b id='1lsak'><form id='1lsak'><ins id='1lsak'></ins><ul id='1lsak'></ul><sub id='1lsak'></sub></form><legend id='1lsak'></legend><bdo id='1lsak'><pre id='1lsak'><center id='1lsak'></center></pre></bdo></b><th id='1lsak'></th></span></q></dt></tr></i><div id='1lsak'><tfoot id='1lsak'></tfoot><dl id='1lsak'><fieldset id='1lsak'></fieldset></dl></div>

    <legend id='1lsak'><style id='1lsak'><dir id='1lsak'><q id='1lsak'></q></dir></style></legend>
    • <bdo id='1lsak'></bdo><ul id='1lsak'></ul>

      <small id='1lsak'></small><noframes id='1lsak'>

      <tfoot id='1lsak'></tfoot>

      cURL 无法在本地服务器中使用客户端证书

      cURL is unable to use client certificate , in local server(cURL 无法在本地服务器中使用客户端证书)

          <tbody id='DaLRW'></tbody>
      1. <legend id='DaLRW'><style id='DaLRW'><dir id='DaLRW'><q id='DaLRW'></q></dir></style></legend>
      2. <tfoot id='DaLRW'></tfoot>

        • <bdo id='DaLRW'></bdo><ul id='DaLRW'></ul>

            • <i id='DaLRW'><tr id='DaLRW'><dt id='DaLRW'><q id='DaLRW'><span id='DaLRW'><b id='DaLRW'><form id='DaLRW'><ins id='DaLRW'></ins><ul id='DaLRW'></ul><sub id='DaLRW'></sub></form><legend id='DaLRW'></legend><bdo id='DaLRW'><pre id='DaLRW'><center id='DaLRW'></center></pre></bdo></b><th id='DaLRW'></th></span></q></dt></tr></i><div id='DaLRW'><tfoot id='DaLRW'></tfoot><dl id='DaLRW'><fieldset id='DaLRW'></fieldset></dl></div>
              • <small id='DaLRW'></small><noframes id='DaLRW'>

                本文介绍了cURL 无法在本地服务器中使用客户端证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我使用 XAMPP 设置了本地服务器.我有两个 PHP 脚本,一个发送者和一个接收者.我正在尝试使用 HTTP over SSL (HTTPS) 将 XML 文件从发送方发送到接收方.

                I set up a local server using XAMPP. I have two PHP scripts , a sender and a receiver. I am trying to send an XML file from the sender to the receiver using HTTP over SSL (HTTPS).

                我创建了一个自签名证书,配置了 XAMPP,并且我在我的发件人上使用了这个代码:

                I created a self signed certificate, configured XAMPP, and I am using this code on my sender :

                <?php
                  /*
                   * XML Sender/Client.
                   */
                  // Get our XML. You can declare it here or even load a file.
                
                
                  $xml = file_get_contents("data.xml");
                
                  // We send XML via CURL using POST with a http header of text/xml.
                  $ch = curl_init();
                
                  //curl_setopt($ch, CURLOPT_SSLVERSION,3);
                
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
                  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
                
                  curl_setopt($ch, CURLOPT_CAINFO,  getcwd().'ipm.crt');
                  curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'ipm.pem');
                
                  curl_setopt($ch, CURLOPT_SSLCERTPASSWD,'pass');
                
                  //i use this line only for debugging through fiddler. Must delete after done with debugging.
                  curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
                
                  // set URL and other appropriate options
                  curl_setopt($ch, CURLOPT_URL, "https://ipv4.fiddler/iPM/receiver.php");
                  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
                  curl_setopt($ch, CURLOPT_HEADER, 0);
                  curl_setopt($ch, CURLOPT_POST, 1);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
                  curl_setopt($ch, CURLOPT_REFERER, 'https://ipv4.fiddler/iPM/receiver.php');
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  $ch_result = curl_exec($ch);
                  echo "Result = ".$ch_result;
                
                  echo 'Curl error: ' . curl_error($ch);
                
                  curl_close($ch);
                  // Print CURL result.
                ?>
                

                但是我总是收到此错误:Curl 错误:无法使用客户端证书(未找到密钥或密码错误?)

                However i always get this error : Curl error: unable to use client certificate (no key found or wrong pass phrase?)

                我可能会做错什么?密码是pass这个词.

                What can i possibly do wrong? The passphrase IS the word pass .

                我通过以下方式创建了我的 .crt:

                I created my .crt by doing :

                openssl req -config openssl.cnf -new -out ipm.csr -keyout ipm.pem
                
                openssl rsa -in ipm.pem -out ipm.key
                
                openssl x509 -in ipm.csr -out ipm.crt -req -signkey ipm.key -days 365
                

                我不想将 SSL_VERIFYPEERSSL_VERIFYHOST 设置为 false.

                I don't want to put the SSL_VERIFYPEER and SSL_VERIFYHOST to false.

                推荐答案

                尝试像这样交换文件:

                curl_setopt($ch, CURLOPT_CAINFO, getcwd().'ipm.pem');
                curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'ipm.crt');
                

                我怀疑你把它们弄错了.

                I suspect you have them the wrong way round.

                这篇关于cURL 无法在本地服务器中使用客户端证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <tfoot id='9kkeC'></tfoot>

                  <legend id='9kkeC'><style id='9kkeC'><dir id='9kkeC'><q id='9kkeC'></q></dir></style></legend>

                    <i id='9kkeC'><tr id='9kkeC'><dt id='9kkeC'><q id='9kkeC'><span id='9kkeC'><b id='9kkeC'><form id='9kkeC'><ins id='9kkeC'></ins><ul id='9kkeC'></ul><sub id='9kkeC'></sub></form><legend id='9kkeC'></legend><bdo id='9kkeC'><pre id='9kkeC'><center id='9kkeC'></center></pre></bdo></b><th id='9kkeC'></th></span></q></dt></tr></i><div id='9kkeC'><tfoot id='9kkeC'></tfoot><dl id='9kkeC'><fieldset id='9kkeC'></fieldset></dl></div>
                          <bdo id='9kkeC'></bdo><ul id='9kkeC'></ul>

                            <tbody id='9kkeC'></tbody>

                          <small id='9kkeC'></small><noframes id='9kkeC'>