標籤: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)