CentOS7服務器下安裝配置SSL


實驗目的

  • 掌握SSL證書的基本概念
  • 掌握使用Openssl手動創建證書

實驗原理

1.了解什么是SSL
  SSL證書是數字證書的一種,類似於駕駛證、護照和營業執照的電子副本。
  SSL證書通過在客戶端瀏覽器和Web服務器之間建立一條SSL安全通道。
2.SSL證書
  全協議是由Netscape Communication公司設計開發。該安全協議主要用來提供對用戶和服務器的認證;對傳送的數據進行加密和隱藏;確保數據在傳送中不被改變,即數據的完整性,現已成為該領域中全球化的標准。由於SSL技術已建立到所有主要的瀏覽器和WEB服務器程序中,因此,僅需安裝服務器證書就可以激活該功能了)。即通過它可以激活SSL協議,實現數據信息在客戶端和服務器之間的加密傳輸,可以防止數據信息的泄露。保證了雙方傳遞信息的安全性,而且用戶可以通過服務器證書驗證他所訪問的網站是否是真實可靠。
3.SSL證書的功能
  確認網站真實性(網站身份認證):用戶需要登錄正確的網站進行在線購物或其它交易活動,但由於互聯網的廣泛性和開放性,使得互聯網上存在着許多假冒、釣魚網站,用戶如何來判斷網站的真實性,如何信任自己正在訪問的網站,可信網站將幫你確認網站的身份。   
  保證信息傳輸的機密性:用戶在登錄網站在線購物或進行各種交易時,需要多次向服務器端傳送信息,而這些信息很多是用戶的隱私和機密信息,直接涉及經濟利益或私密,如何來確保這些信息的安全呢?可信網站將幫您建立一條安全的信息傳輸加密通道。
  在SSL會話產生時,服務器會傳送它的證書,用戶端瀏覽器會自動的分析服務器證書,並根據不同版本的瀏覽器,從而產生40位或128位的會話密鑰,用於對交易的信息進行加密。所有的過程都會自動完成,對用戶是透明的,因而,服務器證書可分為兩種:最低40位和最低128位(這里指的是SSL會話時生成加密密鑰的長度,密鑰越長越不容易破解)證書。   
  最低40位的服務器證書在建立會話時,根據瀏覽器版本不同,可產生40位或128位的SSL會話密鑰用來建立用戶瀏覽器與服務器之間的安全通道。而最低128位的服務器證書不受瀏覽器版本的限制可以產生128位以上的會話密鑰,實現高級別的加密強度,無論是IE或Netscape瀏覽器,即使使用強行攻擊的辦法破譯密碼,也需要10年。
4.SSL證書分類
  SSL證書依據功能和品牌不同分類有所不同,但SSL證書作為國際通用的產品,最為重要的便是產品兼容性(即證書根預埋技術),因為他解決了網民登錄網站的信任問題,網民可以通過SSL證書輕松識別網站的真實身份。目前國際上,常見的證書品牌如VeriSign、GeoTrust等均可以實現該技術。我們以VeriSign證書為例,該類證書分為如下品類:

  • VeriSign 128位SSL支持型證書(VeriSign Secure Site)
  • VeriSign 128位SSL強制型證書(VeriSign Secure Site Pro)  
  • VeriSign 128位EV SSL支持型證書(VeriSign Secure Site with EV):支持綠色地址欄技術  
  • VeriSign 128位EV SSL強制型證書(VeriSign Secure Site Pro with EV ):支持綠色地址欄技術

實驗環境

1.操作系統
  操作機: Linux_Centos7

  • IP:192.168.254.128
  • 網關:192.168.254.255  

目標機:Windows 7
  目標機默認用戶名:administrator  密碼:1234

實驗步驟

一、安裝Apache

yum -y install httpd

二、安裝ssl模塊

yum -y install mod_ssl

三、配置httpd配置文件

3.1修改地址為localhost

vi /etc/httpd/conf/httpd.conf

3.2重啟Apache

/usr/sbin/httpd -k start

四、使用OpenSSL創建自定義證書

4.1安裝OpenSSL

yum -y install openssl

4.2生成服務器私鑰

cd /etc/pki/tls

openssl genrsa -out server.key 1024

server.key是私鑰

[root@localhost /]# cd /etc/pki/tls
[root@localhost tls]# openssl genrsa -out sever.key 1024
Generating RSA private key, 1024 bit long modulus
..............++++++
................++++++
e is 65537 (0x10001)

4.3用私鑰server.key文件生成證書請求文件csr

openssl req -new -key server.key -out server.csr

[root@localhost tls]# openssl req -new -key server.key -out server.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:cn
State or Province Name (full name) []:jiangsu
Locality Name (eg, city) [Default City]:zhenjiang
Organization Name (eg, company) [Default Company Ltd]:ujs
Organizational Unit Name (eg, section) []:aaa
Common Name (eg, your name or your server's hostname) []:www.test.com
Email Address []:weberbon@163.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

4.4生成數字簽名crt文件(證書文件)

openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt

[root@localhost tls]# openssl x509 -days 365 -req -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=cn/ST=jiangsu/L=zhenjiang/O=ujs/OU=aaa/CN=www.test.com/emailAddress=weberbon@163.com
Getting Private key

4.5編輯apache的ssl配置文件

vim /etc/httpd/conf.d/ssl.conf

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/server.crt  ##與證書存放的路徑一致

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/server.key ##與證書存放的路徑一致

4.5再次重啟apache

/usr/sbin/httpd -k restart

五、切換到目標機,打開瀏覽器,輸入配置的IP地址,出現證書不安全,說明配置成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM