dpwh11290 2015-11-01 17:19
浏览 230

CentOS PHP curl无法协商一组可接受的安全参数

On an Ubuntu 14.04.3 this code works fine:

$url_login = "https://test.example.com/login.do";

$cert_file = '/var/www/html/test/cert.pem';
$ssl_key = '/var/www/html/test/cert_private.pem';

$post_fields = 'userAction=1&cancelReason=&cancelType=&account=&memoType=&userText=&userid=99999999&password=xxxxxxxxxxxxxxxx';

$ch = curl_init();

$options = array( 
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_HEADER         => 1,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_SSL_VERIFYHOST => 0,
    CURLOPT_SSL_VERIFYPEER => 0,

    CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
    CURLOPT_VERBOSE        => 0,
    CURLOPT_URL => $url_login ,

    CURLOPT_SSLCERT => $cert_file ,
    CURLOPT_SSLCERTTYPE, 'PEM',
    CURLOPT_SSLKEY => $ssl_key,

    CURLOPT_COOKIESESSION => 1,

    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $post_fields
);

curl_setopt_array($ch , $options);

$output = curl_exec($ch);

The php on Ubuntu is using curl with openssl.

On a Centos 7 if fails with:

Curl Error : SSL peer was unable to negotiate an acceptable set of security parameters.

curl is here with nss.

The "cert.pem" contains only the client certificate with the cert-chain, and the "cert_private.pem" contains the private key not password protected. (-----BEGIN RSA PRIVATE KEY-----).

How can i get the above PHP code work with both? openssl and nss implementations of curl?

  • 写回答

2条回答 默认 最新

  • duankan6894 2015-11-01 20:32
    关注

    How about correcting:

    CURLOPT_SSLCERTTYPE, 'PEM',
    

    to

    CURLOPT_SSLCERTTYPE => 'PEM',
    

    ?

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?