centos7.3編譯安裝OpenSSL1.1.1b

簡介

OpenSSL是一個開放源代碼的軟件庫包,應用程序能夠使用這個包來進行安全通訊,避免竊聽,同時確認另外一端鏈接者的身份。這個包普遍被應用在互聯網的網頁服務器上。linux

安裝

  • 下載:下載地址緩存

    $ wget ftp://ftp.fi.muni.cz/pub/openssl/source/openssl-1.1.1b.tar.gz
  • 安裝:安全

    $ zxvf openssl-1.1.1b.tar.gz 
    $ cd openssl-1.1.1b/
    $ ./config --prefix=/usr/local/openssl-1.1.1b
    $ make && make install
  • 檢查安裝結果:bash

    $ cd /usr/local/openssl-1.1.1b/
    $ ldd bin/openssl
    	linux-vdso.so.1 =>  (0x00007ffc30ef0000)
    	libssl.so.1.1 => not found
    	libcrypto.so.1.1 => not found
    	libdl.so.2 => /lib64/libdl.so.2 (0x00007f3d29a58000)
    	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f3d2983c000)
    	libc.so.6 => /lib64/libc.so.6 (0x00007f3d2946f000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f3d29c5c000)

    由上面的結果發現,OpenSSL依賴的兩個庫沒找到libssl.so.1.一、libcrypto.so.1.1。服務器

  • 執行OpenSSL命令報錯:.net

    $ ./bin/openssl version 
    ./bin/openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
  • 修復上面的報錯開放源代碼

    $ echo "/usr/local/openssl-1.1.1b/lib/" >> /etc/ld.so.conf
    $ ldconfig -v

    即,OpenSSL在編譯安裝時自帶了其依賴的庫文件,默認系統會到/usr/lib、/usr/lib64下尋找全部的庫文件,系統中默認是沒有上述兩個庫的,須要將OpenSSL自帶的庫加入到系統環境。3d

  • 檢查是否修復code

    ./bin/openssl version
    OpenSSL 1.1.1b  26 Feb 2019
  • 此時須要將系統原有的openssl替換掉:blog

    $ openssl version
    OpenSSL 1.0.2k-fips  26 Jan 2017
    
    $ which openssl
    /usr/bin/openssl
    
    $ mv /usr/bin/openssl /usr/bin/openssl.old
    
    $ ln -s /usr/local/openssl-1.1.1b/bin/openssl /usr/bin/openssl
    
    $ openssl version
    OpenSSL 1.1.1b  26 Feb 2019

ldconfig和ldd

在此順便介紹兩個命令:ldconfig和ldd

ldconfig

ldconfig 命令的用途,主要是在默認搜尋目錄(/usr/lib和/usr/lib64)以及動態庫配置文件/etc/ld.so.conf內所列的目錄下,搜索出可共享的動態連接庫(格式lib*.so*),進而建立出動態裝入程序(ld.so)所需的鏈接和緩存文件。

若是要添加動態庫,只須要將庫文件的路徑寫入到/etc/ld.so.conf文件中,而後調用一下 ldconfig命令便可,如 ldconfig -v

ldd

ldd( list dynamic dependencies ),意思是列出動態庫依賴關係。

參考文檔:https://blog.csdn.net/u010977122/article/details/52993560

個人博客即將同步至騰訊雲+社區,邀請你們一同入駐:https://cloud.tencent.com/developer/support-plan?invite_code=3kwilll9kn6sc

相關文章
相關標籤/搜索