Skip to content

解决 curl: Protocol "https" not supported or disabled in libcurl  #77

Description

@johnnian

一、现象

在Centos7环境下,执行curl命令报错:

curl: (1) Protocol "https" not supported or disabled in libcurl

二、解决方法

1、检查curl版本情况

[root@~]# curl -V
curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1
Release-Date: 2017-08-14
Protocols: dict file ftp gopher http imap pop3 rtsp smtp telnet tftp
Features: AsynchDNS IPv6 Largefile UnixSockets

从结果看,系统安装的curl版本确实不支持https,因此需要重新安装curl

2、重新安装openssl版本

执行以下命令:

[root]# vi install_openssl.sh
#!/bin/bash
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar -zxvf openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
./config --prefix=/usr/local/openssl   #如果此步骤报错,需要安装perl以及gcc包
make && make install
mv /usr/bin/openssl /usr/bin/openssl.bak
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v

[root]# sh install_openssl.sh
[root]# openssl version

3、重新安装curl

执行以下命令:

[root]#  vi install_curl.sh
#!/bin/bash
wget https://curl.se/download/curl-7.78.0.tar.gz
tar -zxvf curl-7.78.0.tar.gz
cd curl-7.78.0/
./configure -with-ssh=/usr/local/ssl
make 
make install

[root]#  sh install_curl.sh

在编译curl的时候报错:

vtls/openssl.c: In function ‘Curl_ossl_seed’:
vtls/openssl.c:279:5: error: implicit declaration of function ‘RAND_egd’ [-Werror=implicit-function-declaration]
     int ret = RAND_egd(data->set.str[STRING_SSL_EGDSOCKET]?
    ^
cc1: some warnings being treated as errors
Makefile:2023: recipe for target 'vtls/libcurl_la-openssl.lo' failed
make[2]: *** [vtls/libcurl_la-openssl.lo] Error 1

原因是系统中安装了多个openssl的包,处理方法是:

yum remove openssl-devel

重新执行一遍

cd curl-7.78.0/
./configure -with-ssh=/usr/local/ssl
make 
make install

确认版本号, 已经增加了“https”模块

[root]# curl --version
curl 7.78.0 (x86_64-pc-linux-gnu) libcurl/7.78.0 OpenSSL/1.1.1c zlib/1.2.7
Release-Date: 2021-07-21
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets

三、参考链接

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions