如何使用最新的 openssl 构建 curl?

Pet*_*ter 21 compiling curl

所以我构建了openssl

./config
make
sudo make install
sudo ln -sf /usr/local/ssl/bin/openssl `which openssl`
Run Code Online (Sandbox Code Playgroud)

我建立卷曲

./configure --with-ssl 
make
make install
Run Code Online (Sandbox Code Playgroud)

OpenSSL 看起来安装正确:

openssl version
OpenSSL 1.0.1g 7 Apr 2014
Run Code Online (Sandbox Code Playgroud)

但是 curl 使用旧的 openssl 版本(1.0.1f 而不是 1.0.1g):

curl --version
curl 7.37.0 (x86_64-unknown-linux-gnu) libcurl/7.37.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 libssh2/1.4.3 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 
Run Code Online (Sandbox Code Playgroud)

如何让 curl 使用新版本?

我想尝试最新版本,因为我正在与一些奇怪的 openssl/curl 错误#1 #2 作斗争

编辑:我也试过了./configure --with-ssl=/usr/local/ssl/include/openssl,没有成功

Edit2:到目前为止我还尝试过:

  • sudo ./configure --with-ssl --with-libssl-prefix=/usr/local/ssl
  • ./configure --with-ssl=/usr/local/ssl
  • PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig ./configure
  • PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig ./configure --with-ssl
  • PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig ./configure --with-ssl=/usr/local/ssl/include/openssl

没有成功...

fkr*_*iem 14

您需要指定安装 OpenSSL 的目录(您的符号链接既不必要也不充分)

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

编辑:或者,您可以设置PKG_CONFIG_PATH环境变量(如 所建议./configure --help):

PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig ./configure


Ber*_* B. 10

sudo apt-get install libssl-dev
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
sudo make
sudo make install
Run Code Online (Sandbox Code Playgroud)

我只需要在 ubuntu 15.04 上构建 curl 7.43


Ole*_*ryb 6

当我进行相同的练习时,我发现 curl 根本无法使用 openssl 静态库。无论我在做什么,它总是在寻找动态,所以最终我做了三件对我有用的事情

Configured openssl with enable-shared: ./config enable-shared
Configured curl with openssl: ./configure --with-ssl
Used LD_LIBRARY_PATH: LD_LIBRARY_PATH=/usr/local/lib:/usr/local/ssl/lib /usr/local/bin/curl -V
Run Code Online (Sandbox Code Playgroud)

带有 -V 标志的后一个命令将显示 curl 使用的 openssl 版本。我已将 /usr/local/lib 添加到 LD_LIBRARY_PATH 以确保 curl 使用正确的 libcurl 版本。


Jac*_*nkr 5

这对我来说是一条漫长而艰巨的道路。小时和小时(你知道它是怎么回事)。这是我发现的:

对于Ubuntu 12.04 / 14.04,您必须手动安装opensslcurl

手动安装 openssl 1.0.2g:

sudo apt-get install make # (Install compiling library Make)
wget https://www.openssl.org/source/openssl-1.0.2g.tar.gz # (Download the latest OpenSSL 1.0.2g binaries)
tar -xzvf openssl-1.0.2g.tar.gz # (Extract the tar ball to the local directory)
cd openssl-1.0.2g # (Enter extracted OpenSSL directory)
sudo ./config # (Configure binaries for compiling)
sudo make install # (install configured binaries)
sudo ln -sf /usr/local/ssl/bin/openssl `which openssl` # (This will create a sym link to the new binaries)
openssl version -v
Run Code Online (Sandbox Code Playgroud)

如果您想要 NGHTTP2(可选/推荐):

# Get build requirements
# Some of these are used for the Python bindings
# this package also installs
sudo apt-get install g++ make binutils autoconf automake autotools-dev libtool pkg-config \
  zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev libevent-dev libjansson-dev \
  libjemalloc-dev cython python3-dev python-setuptools

# Build nghttp2 from source
git clone https://github.com/tatsuhiro-t/nghttp2.git
cd nghttp2
autoreconf -i
automake
autoconf
./configure
make
sudo make install
Run Code Online (Sandbox Code Playgroud)

手动安装 curl:

cd ~
sudo apt-get build-dep curl
wget http://curl.haxx.se/download/curl-7.46.0.tar.bz2
tar -xvjf curl-7.46.0.tar.bz2
cd curl-7.46.0
./configure --with-nghttp2 --with-ssl --with-libssl-prefix=/usr/local/ssl # This is the line I had the most trouble with, especially figure out --with-libssl-prefix
make
sudo make install
sudo ldconfig
Run Code Online (Sandbox Code Playgroud)

最后的步骤

sudo ldconfig
sudo service apache2 restart # if you're using apache
Run Code Online (Sandbox Code Playgroud)

现在你已经完成了,试着curl --version确保你在那里看到了正确版本的 openssl。特别是 openssl >= 1.0.2g(如果你选择了 nghttp2)

$ curl --version
curl 7.50.2 (x86_64-pc-linux-gnu) libcurl/7.50.2 OpenSSL/1.0.2k zlib/1.2.8 nghttp2/1.21.0-DEV
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets 
Run Code Online (Sandbox Code Playgroud)

引文:curl opennssl