如何在Ubuntu上安装和构buildOpenSSL 1.0.0?

你可以考虑一个后续问题, 如何在Ubuntu安装OpenSSL C ++库?

我试图在Ubuntu 10.04 LTS上构build一些需要OpenSSL 1.0.0的代码。

Ubuntu 10.04 LTS附带OpenSSL 0.9.8k:

$ openssl version OpenSSL 0.9.8k 25 Mar 2009 

所以在运行sudo apt-get install libssl-dev并构build之后,运行ldd确认我已经链接到0.9.8:

 $ ldd foo ... libssl.so.0.9.8 => /lib/i686/cmov/libssl.so.0.9.8 (0x00110000) ... libcrypto.so.0.9.8 => /lib/i686/cmov/libcrypto.so.0.9.8 (0x002b0000) ... 

我如何安装OpenSSL 1.0.0和1.0.0开发包?

更新 :我在阅读SB的答案(但在尝试之前)写这个更新,因为很明显,我需要解释下载和安装OpenSSL 1.0.0的明显解决scheme不起作用:

成功完成以下操作后(在INSTALL文件中推荐):

  $ ./config $ make $ make test $ make install 

…我仍然得到:

 OpenSSL 0.9.8k 25 Mar 2009 

…和:

 $ sudo apt-get install libssl-dev Reading package lists... Done Building dependency tree Reading state information... Done libssl-dev is already the newest version. The following packages were automatically installed and are no longer required: linux-headers-2.6.32-21 linux-headers-2.6.32-21-generic Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 

…和(只是为了确保)重build我的代码后,ldd仍然返回相同的东西。

更新#2 :我添加了“-I / usr / local / ssl / include”和“-L / usr / local / ssl / lib”选项(由SBbuild议)到我的makefile,但是现在我得到了一堆未定义的引用编译错误,例如:

 /home/dspitzer/foo/foo.cpp:86: undefined reference to `BIO_f_base64' /home/dspitzer/foo/foo.cpp:86: undefined reference to `BIO_new' 

/ usr / local / ssl / include /只包含一个openssl目录(其中包含许多.h文件),所以我也试过“-I / usr / local / ssl / include / openssl”,但是得到了同样的错误。

更新#3 :我试图改变OpenSSL包括(例如):

 #include <openssl/bio.h> 

…至:

 #include "openssl/bio.h" 

…在.cpp源文件中,但仍然得到相同的未定义的参考错误。

更新#4 :我现在意识到那些未定义的引用错误是链接器错误。 如果我从我的Makefile中删除“-L / usr / local / ssl / lib”,我不会得到错误(但是它链接到OpenSSL 0.9.8)。 / usr / local / ssl / lib /的内容是:

 $ ls /usr/local/ssl/lib/ engines libcrypto.a libssl.a pkgconfig 

我加了-lcrypto,错误消失了。

从这里获取1.0.0a源代码。

 # tar -xf openssl-1.0.0a.tar.gz # cd openssl-1.0.0a # ./config # sudo make install 

这个默认放在/ usr / local / ssl中

在构建时,需要告诉gcc在/ usr / local / ssl / include中查找头文件,并在lib / usr / local / ssl / lib中链接库文件。 您可以通过执行以下操作来指定它:

 gcc test.c -o test -I/usr/local/ssl/include -L/usr/local/ssl/lib -lssl -lcrypto 

编辑不要覆盖任何系统库。 最好将新的库保存在/ usr / local中。 覆盖Ubuntu默认值可能会危害您的健康并破坏您的系统。

另外,我刚刚在Ubuntu 10.04 VM中尝试了这个路径,所以我错了。 固定。

请注意,不需要更改LD_LIBRARY_PATH,因为默认情况下链接的openssl库是静态库(至少在缺省情况下 – 可能会在./config步骤中将它们配置为动态库)

您可能需要链接到libcrypto,因为您正在使用一些在libcrypto包中构建和定义的调用。 OpenSSL 1.0.0实际上构建了两个库libcrypto和libssl。

编辑2添加-lcrypto gcc行。

代替:

  $ ./config $ make $ make test $ make install 

做:

  $ sudo ./config --prefix=/usr $ sudo make $ sudo make test $ sudo make install 

这将帮助您更新到openssl 1.0.1g来修补CVE-2014-0160(Heartbleed)。

OpenSSL安全咨询[2014年4月7日]

TLS心跳读取溢出(CVE-2014-0160)

处理TLS心跳扩展时缺少边界检查可用于向连接的客户端或服务器显示高达64k的内存。

只有1.0.1和1.0.2-beta版本的OpenSSL受到影响,包括1.0.1f和1.0.2-beta1。

感谢Google Security的Neel Mehta发现这个错误,感谢Adam Langley和Bodo Moeller准备修复。

受影响的用户应该升级到OpenSSL 1.0.1g。 无法立即升级的用户可以使用-DOPENSSL_NO_HEARTBEATS重新编译OpenSSL。

1.0.2将固定在1.0.2-beta2。

资料来源: https : //www.openssl.org/news/secadv_20140407.txt

下面是为我解决的问题: 在Ubuntu上升级最新版本的OpenSSL

抄录主要信息:

 Download the OpenSSL v1.0.0g source: $ wget http://www.openssl.org/source/openssl-1.0.0g.tar.gz Unpack the archive and install: $ tar xzvf openssl-1.0.0g.tar.gz $ cd openssl-1.0.0g $ ./config $ make $ make test $ sudo make install All files, including binaries and man pages are install under the directory /usr/local/ssl. To ensure users use this version of OpenSSL instead of the previous version you must update the paths for man pages and binaries. Edit the file /etc/manpath.config adding the following line before the first MANPATH_MAP: MANPATH_MAP /usr/local/ssl/bin /usr/local/ssl/man Update the man database (I honestly can't remember and don't know for sure if this command was necessary - maybe try without it and at the end when testing if the man pages are still the old versions come back and run mandb): sudo mandb Edit the file /etc/environment and insert the path for OpenSSL binaries (/usr/local/ssl/bin) before the path for Ubuntu's version of OpenSSL (/usr/bin). My environment file looks like this: PATH="/usr/local/sbin:/usr/local/bin:/usr/local/ssl/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" Logout and login and test: $ openssl version OpenSSL 1.0.0g 18 Jan 2012 Also test the man pages by running man openssl and at the very bottom in the left hand corner it should report 1.0.0g. Note that although the users will now automatically use the new version of OpenSSL, existing programs (eg Apache) may not as they are linked against the libraries from the Ubuntu version.