Nginx如何升級Openssl

来源:https://www.cnblogs.com/xunweidezui/archive/2023/03/11/17204841.html
-Advertisement-
Play Games

1. 什麼是Openssl? 在電腦網路上,OpenSSL是一個開放源代碼的軟體庫包,應用程式可以使用這個包來進行安全通信,避免竊聽,同時確認另一端連線者的身份。這個包廣泛被應用在互聯網的網頁伺服器上。 其主要庫是以C語言所寫成,實現了基本的加密功能,實現了SSL與TLS協議。OpenSSL可以運 ...


1. 什麼是Openssl?

在電腦網路上,OpenSSL是一個開放源代碼的軟體庫包,應用程式可以使用這個包來進行安全通信,避免竊聽,同時確認另一端連線者的身份。這個包廣泛被應用在互聯網的網頁伺服器上。

其主要庫是以C語言所寫成,實現了基本的加密功能,實現了SSL與TLS協議。OpenSSL可以運行在OpenVMS、 Microsoft Windows以及絕大多數類Unix操作系統上(包括Solaris,Linux,Mac OS X與各種版本的開放源代碼BSD操作系統)。

雖然此軟體是開放源代碼的,但其許可書條款與GPL有衝突之處,故GPL軟體使用OpenSSL時(如Wget)必須對OpenSSL給予例外。
https://www.openssl.org/

2. 什麼是心臟滴血?

心臟出血漏洞(英語:Heartbleed bug),簡稱為心血漏洞,是一個出現在加密程式庫OpenSSL的安全漏洞,該程式庫廣泛用於實現互聯網的傳輸層安全(TLS)協議。它於2012年被引入了OpenSSL中,2014年4月首次向公眾披露。只要使用的是存在缺陷的OpenSSL實例,無論是伺服器還是客戶端,都可能因此而受到攻擊。此問題的原因是在實現TLS的心跳擴展時沒有對輸入進行適當驗證(缺少邊界檢查,因此漏洞的名稱來源於“心跳”(heartbeat。該程式錯誤屬於緩衝區過讀,即可以讀取的數據比應該允許讀取的還多。

心臟出血在通用漏洞披露(CVE)系統中的編號為CVE-2014-0160。加拿大網路事故響應中心發佈安全公告,提醒系統管理員註意漏洞。2014年4月7日,即漏洞公開披露的同一天,OpenSSL發佈了修複後的版本。
截至2014年5月20日,在80萬最熱門的啟用TLS的網站中,仍有1.5%易受心臟出血漏洞的攻擊。
因為缺陷在於OpenSSL的實現,而不是SSL/TLS協議本身,所以除了OpenSSL之外的其他TLS實現方式,如GnuTLS、Mozilla的網路安全服務(NSS)和Windows平臺的TLS實現都不受影響。

3. Nginx升級openssl

3.1 查看現openssl版本

# nginx -V
nginx version: nginx/1.22.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled

3.2 官方下載新的openssl安裝包並解壓

也可在GitHub上下載: https://github.com/openssl/openssl/releases

# wget https://www.openssl.org/source/openssl-3.0.8.tar.gz -P /opt/ --no-check-certificate
]# tar -xf openssl-3.0.8.tar.gz 

3.3 重新編譯Nginx

# ./configure  --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-openssl=/opt/openssl-3.0.8

3.4 編譯時報錯

# make 
make -f objs/Makefile
make[1]: 進入目錄“/usr/local/src/nginx-1.22.1”
cd /opt/openssl-3.0.8 \
&& if [ -f Makefile ]; then make clean; fi \
&& ./config --prefix=/opt/openssl-3.0.8/.openssl no-shared no-threads  \
&& make \
&& make install_sw LIBDIR=lib
Can't locate IPC/Cmd.pm in @INC (@INC contains: /opt/openssl-3.0.8/util/perl /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /opt/openssl-3.0.8/external/perl/Text-Template-1.56/lib) at /opt/openssl-3.0.8/util/perl/OpenSSL/config.pm line 19.
BEGIN failed--compilation aborted at /opt/openssl-3.0.8/util/perl/OpenSSL/config.pm line 19.
Compilation failed in require at /opt/openssl-3.0.8/Configure line 23.
BEGIN failed--compilation aborted at /opt/openssl-3.0.8/Configure line 23.
make[1]: *** [/opt/openssl-3.0.8/.openssl/include/openssl/ssl.h] 錯誤 2

3.5 解決方法

yum install -y perl-CPAN
[root@haitang-nginx-test openssl-3.0.8]# perl -MCPAN -e shell

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] yes

 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')

3.6 安裝預設的包

cpan[1]> install IPC/Cmd.pm 
..............................................................DONE
Fetching with HTTP::Tiny:
http://www.cpan.org/modules/03modlist.data.gz
Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Running install for module 'IPC::Cmd'
Running make for B/BI/BINGOS/IPC-Cmd-1.04.tar.gz
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/id/B/BI/BINGOS/IPC-Cmd-1.04.tar.gz
Fetching with HTTP::Tiny:
http://www.cpan.org/authors/id/B/BI/BINGOS/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/B/BI/BINGOS/IPC-Cmd-1.04.tar.gz ok
Scanning cache /root/.cpan/build for sizes
DONE

  CPAN.pm: Building B/BI/BINGOS/IPC-Cmd-1.04.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Locale::Maketext::Simple 0 not found.
Warning: prerequisite Module::Load::Conditional 0.66 not found.
Warning: prerequisite Params::Check 0.20 not found.
Warning: prerequisite Test::More 0 not found.
Writing Makefile for IPC::Cmd
Could not read metadata file. Falling back to other methods to determine prerequisites
---- Unsatisfied dependencies detected during ----
----        BINGOS/IPC-Cmd-1.04.tar.gz        ----
    Test::More [requires]
    Locale::Maketext::Simple [requires]
    Module::Load::Conditional [requires]
    Params::Check [requires]

3.7 安裝完成繼續執行編譯操作。

# ./configure  --prefix=/apps/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-openssl=/opt/openssl-3.0.8
checking for OS
 + Linux 3.10.0-1062.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... found

3.8 執行make && make install

# make && make install
cp objs/nginx '/apps/nginx/sbin/nginx'
test -d '/apps/nginx/conf' \
	|| mkdir -p '/apps/nginx/conf'
cp conf/koi-win '/apps/nginx/conf'
cp conf/koi-utf '/apps/nginx/conf'
cp conf/win-utf '/apps/nginx/conf'
test -f '/apps/nginx/conf/mime.types' \
	|| cp conf/mime.types '/apps/nginx/conf'
cp conf/mime.types '/apps/nginx/conf/mime.types.default'
test -f '/apps/nginx/conf/fastcgi_params' \
	|| cp conf/fastcgi_params '/apps/nginx/conf'
cp conf/fastcgi_params \
	'/apps/nginx/conf/fastcgi_params.default'
test -f '/apps/nginx/conf/fastcgi.conf' \
	|| cp conf/fastcgi.conf '/apps/nginx/conf'
cp conf/fastcgi.conf '/apps/nginx/conf/fastcgi.conf.default'
test -f '/apps/nginx/conf/uwsgi_params' \
	|| cp conf/uwsgi_params '/apps/nginx/conf'
cp conf/uwsgi_params \
	'/apps/nginx/conf/uwsgi_params.default'
test -f '/apps/nginx/conf/scgi_params' \
	|| cp conf/scgi_params '/apps/nginx/conf'
cp conf/scgi_params \
	'/apps/nginx/conf/scgi_params.default'
test -f '/apps/nginx/conf/nginx.conf' \
	|| cp conf/nginx.conf '/apps/nginx/conf/nginx.conf'
cp conf/nginx.conf '/apps/nginx/conf/nginx.conf.default'
test -d '/apps/nginx/logs' \
	|| mkdir -p '/apps/nginx/logs'
test -d '/apps/nginx/logs' \
	|| mkdir -p '/apps/nginx/logs'
test -d '/apps/nginx/html' \
	|| cp -R html '/apps/nginx'
test -d '/apps/nginx/logs' \
	|| mkdir -p '/apps/nginx/logs'
make[1]: 離開目錄“/usr/local/src/nginx-1.22.1”

3.9 查看是否升級成功

# nginx -V
nginx version: nginx/1.22.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
built with OpenSSL 3.0.8 7 Feb 2023
TLS SNI support enabled
我們一直奔跑在進步的旅途
您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 概述 非同步這個概念在不同語境下有不同的解釋,比如在一個單核CPU里開啟兩個線程執行兩個函數,通常認為這種調用是非同步的,但對於CPU來說它是單核不可能同時運行兩個函數,不過是由系統調度在不同的時間分片中執行。一般來說,如果兩個工作能同時進行,就認為是非同步的。在編程中,它通常代表函數的調用可以在不執行完 ...
  • 1 - 文本控制項 我們熟悉的文本控制項不外乎TextBox,RichTextBox。在WPF中還有一個PasswordBox,不過區分於前者的區別就是PasswordBox是直接繼承於Control的比較特殊,前三者是繼承於TextBoxBase的。接下來我們就簡單介紹下這幾個控制項。 1.1 - 多行 ...
  • 3. 配置提供程式 上面提到,通過 IConfigurationBuilder 的實現類對象,我們可以自由地往配置系統中添加不同的配置提供程式,從而獲取不同來源的配置信息。.NET Core 中,微軟提供了以下這些內置的配置提供程式: 文件配置提供程式 環境變數配置提供程式 命令行配置提供程式 Az ...
  • 說明,由於對圖形化感興趣,之前也從來沒有大的接觸,只是簡單的使用GDI+繪圖,比如驗證碼、水印等簡單操作,至此想多深入瞭解一下。 版本OpenTK 4.7.4,目前封裝OpenGL最好的庫,包含OpenGL, OpenAL & OpenCL 目前的理解:圖形圖像是每幀的繪製和控制,它有自己的時間軸, ...
  • 前言: 在我們的業務中,展示列表時經常會聯表查詢,比如說我們有學生表和班級表,表結構如下:包含了學生表、班級表以及列表返回模型 /// <summary> /// 學生表 /// </summary> public class StudentInfo { /// <summary> /// 標識 / ...
  • .NET從資料庫讀取數據反序列化時,如果只有有參的構造函數,沒有無參構造函數報錯。 在.NET中,反序列化是將二進位數據轉換回.NET對象的過程。當你從資料庫讀取數據反序列化時,反序列化過程需要使用對象的構造函數創建一個新的對象,並使用反序列化器將二進位數據填充到該對象中。 如果你的.NET類中只有 ...
  • 最近遇一個問題,一個程式調用另一個程式的文件,結果另一個程式的文件被占用,使用不了文件。這時候的解決方案就是把另一個程式的文件拷貝到當前程式就可以了。本文介紹用C#拷貝文件的三種方式。 1、Copy 這個是C#比較常用的拷貝文件方法,是File下麵的一個方法,這種適用於沒有特殊要求的文件拷貝,使用方 ...
  • (索引) 寫在前面 這是《BitBake使用攻略》系列文章的第三篇,主要講解BitBake的基本語法。由於此篇的實驗依賴於第一篇的項目,建議先將HelloWorld項目完成之後再食用此篇為好。 第一篇的鏈接在這:BitBake使用攻略--從HelloWorld講起。 1. BitBake中的任務 對 ...
一周排行
    -Advertisement-
    Play Games
  • 基於.NET Framework 4.8 開發的深度學習模型部署測試平臺,提供了YOLO框架的主流系列模型,包括YOLOv8~v9,以及其系列下的Det、Seg、Pose、Obb、Cls等應用場景,同時支持圖像與視頻檢測。模型部署引擎使用的是OpenVINO™、TensorRT、ONNX runti... ...
  • 十年沉澱,重啟開發之路 十年前,我沉浸在開發的海洋中,每日與代碼為伍,與演算法共舞。那時的我,滿懷激情,對技術的追求近乎狂熱。然而,隨著歲月的流逝,生活的忙碌逐漸占據了我的大部分時間,讓我無暇顧及技術的沉澱與積累。 十年間,我經歷了職業生涯的起伏和變遷。從初出茅廬的菜鳥到逐漸嶄露頭角的開發者,我見證了 ...
  • C# 是一種簡單、現代、面向對象和類型安全的編程語言。.NET 是由 Microsoft 創建的開發平臺,平臺包含了語言規範、工具、運行,支持開發各種應用,如Web、移動、桌面等。.NET框架有多個實現,如.NET Framework、.NET Core(及後續的.NET 5+版本),以及社區版本M... ...
  • 前言 本文介紹瞭如何使用三菱提供的MX Component插件實現對三菱PLC軟元件數據的讀寫,記錄了使用電腦模擬,模擬PLC,直至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1. PLC開發編程環境GX Works2,GX Works2下載鏈接 https:// ...
  • 前言 整理這個官方翻譯的系列,原因是網上大部分的 tomcat 版本比較舊,此版本為 v11 最新的版本。 開源項目 從零手寫實現 tomcat minicat 別稱【嗅虎】心有猛虎,輕嗅薔薇。 系列文章 web server apache tomcat11-01-官方文檔入門介紹 web serv ...
  • 1、jQuery介紹 jQuery是什麼 jQuery是一個快速、簡潔的JavaScript框架,是繼Prototype之後又一個優秀的JavaScript代碼庫(或JavaScript框架)。jQuery設計的宗旨是“write Less,Do More”,即倡導寫更少的代碼,做更多的事情。它封裝 ...
  • 前言 之前的文章把js引擎(aardio封裝庫) 微軟開源的js引擎(ChakraCore))寫好了,這篇文章整點js代碼來測一下bug。測試網站:https://fanyi.youdao.com/index.html#/ 逆向思路 逆向思路可以看有道翻譯js逆向(MD5加密,AES加密)附完整源碼 ...
  • 引言 現代的操作系統(Windows,Linux,Mac OS)等都可以同時打開多個軟體(任務),這些軟體在我們的感知上是同時運行的,例如我們可以一邊瀏覽網頁,一邊聽音樂。而CPU執行代碼同一時間只能執行一條,但即使我們的電腦是單核CPU也可以同時運行多個任務,如下圖所示,這是因為我們的 CPU 的 ...
  • 掌握使用Python進行文本英文統計的基本方法,並瞭解如何進一步優化和擴展這些方法,以應對更複雜的文本分析任務。 ...
  • 背景 Redis多數據源常見的場景: 分區數據處理:當數據量增長時,單個Redis實例可能無法處理所有的數據。通過使用多個Redis數據源,可以將數據分區存儲在不同的實例中,使得數據處理更加高效。 多租戶應用程式:對於多租戶應用程式,每個租戶可以擁有自己的Redis數據源,以確保數據隔離和安全性。 ...