簡體   English   中英

如何在Ubuntu上安裝和構建OpenSSL 1.0.0?

[英]How do I install and build against OpenSSL 1.0.0 on Ubuntu?

您可以將此問題視為如何在Ubuntu上安裝OpenSSL C ++庫的后續問題

我正在嘗試在需要OpenSSL 1.0.0的Ubuntu 10.04 LTS上構建一些代碼。

Ubuntu 10.04 LTS附帶OpenSSL 0.9.8k:

$ openssl version
OpenSSL 0.9.8k 25 Mar 2009

所以在運行sudo apt-get install libssl-dev並構建之后,運行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的明顯解決方案不起作用:

成功執行以下操作后(在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.

...並且(只是為了確保)在重建我的代碼之后,ldd仍然返回相同的東西。

更新#2 :我在我的makefile中添加了“-I / usr / local / ssl / include”和“-L / usr / local / ssl / lib”選項(由SB建議),但我現在得到一堆undefine引用編譯錯誤,例如:

/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中查找頭文件,並與/ usr / local / ssl / lib中的libs鏈接。 您可以通過執行以下操作來指定:

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 (e.g. Apache) may not as they are linked against the libraries from the Ubuntu version.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM