PHP CURL - cURL错误35:错误:1414D172:SSL例程:tls12_check_peer_sigalg:签名类型错误。

14

我想在 PHP 7.3.90 中发起一个 cURL 请求

curl -V
curl 7.64.0 (x86_64-pc-linux-gnu) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 

    $ch = curl_init();
    // 2. set the options, including the url
    curl_setopt($ch, CURLOPT_URL, "https://mydomain/get-token");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("App-Key: YOUR-KEY-HERE"));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);

答案是

"cURL error 35: error:1414D172:SSL routines:tls12_check_peer_sigalg:wrong signature type (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"

我用curl命令遇到了同样的问题,不过我解决了它

[system_default_sect]
MinProtocol = TLSv1.2
CipherString = DEFAULT@SECLEVEL=1

取代

[system_default_sect]
MinProtocol = TLSv1.2
CipherString = DEFAULT@SECLEVEL=2

https://github.com/curl/curl/issues/4097OpenSSL v1.1.1 ssl_choose_client_version unsupported protocol

我应该使用哪个curl选项来解决这个错误?

谢谢。


1
不要关闭 CURLOPT_SSL_VERIFYHOSTCURLOPT_SSL_VERIFYPEER,这可能会带来安全风险!如果您的服务器缺少证书包,请参考此处获取证书包的方法。 - Dharman
如果您按照Maxim的回答在/etc/ssl/openssl.cnf中进行了更改,则只需要重新启动PHP服务即可。 - Yvan
5个回答

15

我知道这个问题很旧了,但是当我在处理一些旧的coughhermescaugh API时遇到了同样的问题。

我也不想为整个系统设置seclevel为1。你要找的是以下内容:

 curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');

把那段代码放入您的应用程序中,这样您就可以通过这个请求了。当然,这并不是最安全的方式,但是当API没有正确设置时,您别无选择。


9

在将OpenSSL 1.1.0升级到1.1.1后,我遇到了这个问题,我的操作系统是Debian。

我在这里找到了解决方案:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900984

/etc/ssl/openssl.cnf中,用SECLEVEL 1替换SECLEVEL 2,因为SECLEVEL 2阻止了SHA1加密,而在我的情况下,Moneris仅支持已弃用的SHA1签名。


6

在我看来,更好的逐步说明如何安装1.1.1g可以在https://askubuntu.com/a/1102966/657482找到。 - not2savvy

1
在安装Ubuntu 22.04后,我遇到了这个问题,并且需要在SECLEVEL 0中替换SECLEVEL 2。
  • /etc/ssl/openssl.cnf

已经修复。 零非常重要。


0

仅仅将DEFAULT@SECLEVEL设置为1并不能解决问题,因为我需要在使用OpenSSL 1.1.1f 31 Mar 2020Ubuntu 20.04.3 LTS上修复该问题。我在https://askubuntu.com/a/1233456/306766找到了解决方案,对我很有帮助。

You need to add this to the beginning of your config file (/etc/ssl/openssl.cnf):

openssl_conf = default_conf

And then this to the end:

[ default_conf ]

ssl_conf = ssl_sect

[ssl_sect]

system_default = system_default_sect

[system_default_sect] MinProtocol = TLSv1.2 CipherString =
DEFAULT:@SECLEVEL=1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接