curl 不支援 https(Protocol https not supported or disabled in libcurl)

來源:互聯網
上載者:User

標籤:curl   https   

    curl預設安裝完後是只支援http協議而不支援https協議的。

    可以先用curl -V查看當前curl支援哪些協議:

[[email protected] /]# curl -V

curl 7.19.4 (x86_64-unknown-linux-gnu) libcurl/7.19.4 OpenSSL/1.0.2k zlib/1.2.11

Protocols: tftp ftp telnet dict http file ftps

可以看到並不支援https協議。若用curl命令訪問https時就會報錯:

Protocol https not supported or disabled in libcurl

        若需要讓curl支援https協議,需要安裝openssl並在curl中使之生效:

下載並安裝openssl包(若已經裝了則不需要重新安裝):

wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz

wget https://www.openssl.org/source/openssl-fips-2.0.14.tar.gz

安裝openssl-fips:

tar xvf openssl-fips-2.0.14.tar.gz

cd openssl-fips-2.0.14&&./config&&make&&make install

安裝openssl:

tar xvf openssl-1.0.2k.tar.gz

./config shared --prefix=/usr/local/ssl&& make && make install

# 更新ld

echo "/usr/local/ssl/lib" >> /etc/ld.so.conf

ldconfig -v

# 配置openssl庫

cp /usr/local/ssl/lib/libssl.so.1.0.0 /usr/lib64;cp/usr/local/ssl/lib/libcrypto.so.1.0.0 /usr/lib64

chmod 555 /usr/lib64/libssl.so.1.0.0;chmod 555/usr/lib64/libcrypto.so.1.0.0

ln -s /usr/lib64/libcrypto.so.1.0.0/usr/lib64/libcrypto.so.10;ln -s /usr/lib64/libssl.so.1.0.0 /usr/lib64/libssl.so.10

ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl;ln -s/usr/local/ssl/include/openssl /usr/include/openssl

# 查看openssl版本

openssl version -a

OpenSSL 1.0.2k  26 Jan2017

built on: reproducible build, date unspecified

platform: linux-x86_64

options:  bn(64,64)rc4(16x,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 

重新編譯curl

./configure –with-ssl=/usr/local/ssl

make

make install

查看curl是否已經支援https協議:

curl -V

curl 7.19.4 (x86_64-unknown-linux-gnu) libcurl/7.19.4 OpenSSL/1.0.2k zlib/1.2.11

Protocols: tftp ftp telnet dict http file https ftps 

可以看到已經支援https協議了。



本文出自 “L.P.F” 部落格,請務必保留此出處http://liupengfang1015.blog.51cto.com/6627801/1945846

curl 不支援 https(Protocol https not supported or disabled in libcurl)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.