馬哥教育21期網絡班—第11周課程+練習—-成長進行時–不退步–上

1、詳細描述一次加密通訊的過程,結合圖示最佳。

對稱加密.jpeg

網絡傳輸數據 .jpeg

對稱加密:
加密和解密使用同一個密鑰;				缺點:如何通信方多的話,需要保存多組密鑰
公鑰加密:密鑰是成對兒出現
			公鑰:公開給所有人;pubkey
			私鑰:自己留存,必須保證其私密性;secret key
			特點:用公鑰加密的數據,只能使用與之配對兒的私鑰解密;反之亦然;
			數字簽名:主要在于讓接收方確認發送方身份;
			發送方生成數據--->自己私鑰加密這段數據--->公鑰解密
			aim--->拿著bob的公鑰--->解密--->數據是bob發送的
			1、確定是bob發送的2、數據沒有被篡改
			bob-->取數據特征碼--->加密特征碼--->解密特征碼-->對比特征碼
			密鑰交換:發送方用對方的公鑰加密一個對稱密鑰,并發送給對方;
			給的是PKI
			bob--->aim數據 
			需要拿的aim的公鑰--->密鑰交換實現
			利用aim公鑰加密--->發給aim--->aim利用私鑰解密
			bob-->拿到aim的公鑰--->加密數據--->加密后數據--->aim--->利用自己私鑰解密
			對稱--->加密--->密鑰

2、描述創建私有CA的過程,以及為客戶端發來的證書請求進行辦法證書。

使用Openssl搭建私有CA流程

常見文件后綴名的命名:    
    .key格式:私有的密鑰    
    .crt格式:證書文件,certificate的縮寫    
    .csr格式:證書簽名請求(證書請求文件),含有公鑰信息,certificate signing request的縮寫    
    .crl格式:證書吊銷列表,Certificate Revocation List的縮寫    
    .pem格式:用于導出,導入證書時候的證書的格式,有證書開頭,結尾的格式

openssl建立私有CA:

1、生成密鑰    
2、自簽署證書

節點:    
     1、生成密鑰對兒    
     2、生成證書簽署請求    
     3、把請求發送給CA
CA:    
     1、驗正請求者信息;    
     2、簽署證書;    
     3、把簽好的證書發送給請求者;

一、建立CA服務器:

1、生成密鑰    
    # (umask 077; openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)1 # (umask 077; openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)2 Generating RSA private key, 2048 bit long modulus3 ......+++4 .........................................+++5 e is 65537 (0x10001)2、自簽證書  
    # openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 3655
    req: 生成證書簽署請求  
        -news: 新請求  
        -key /path/to/keyfile: 指定私鑰文件  
        -out /path/to/somefile:  
        -x509: 生成自簽署證書  
        -days n: 有效天數 1 # openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/ 
 2 CA/cacert.pem -days 3650 
 3 You are about to be asked to enter information that will be incorporated 
 4 into your certificate request. 5 What you are about to enter is what is called a Distinguished Name or a DN. 
 6 There are quite a few fields but you can leave some blank 
 7 For some fields there will be a default value, 
 8 If you enter '.', the field will be left blank. 
 9 ----- 10 Country Name (2 letter code) [XX]:cn                          #國家
 11 State or Province Name (full name) []:hn                      #省份
 12 Locality Name (eg, city) [Default City]:zz                    #市區
 13 Organization Name (eg, company) [Default Company Ltd]:luo     #組織名稱
 14 Organizational Unit Name (eg, section) []:tech                #部門
 15 Common Name (eg, your name or your server's hostname) []:stu19.magedu.com        #服務器名稱
 16 Email Address []:luo@magedu.com                                #郵件地址3、初始化工作環境  
    # touch /etc/pki/CA/{index.txt,serial}  
    # echo 01 > /etc/pki/CA/serial1 # touch /etc/pki/CA/{index.txt,serial}2 # echo 01 > /etc/pki/CA/serial

二、節點申請證書:

(一) 節點生成請求  
    1、生成密鑰對兒  
    # (umask 077; openssl genrsa -out /etc/httpd/ssl/httpd.key 2048)
本文中,CA和節點在同一臺主機
1 mkdir /etc/httpd/ssl
2 cd /etc/httpd/ssl
3 # (umask 077; openssl genrsa -out /etc/httpd/ssl/httpd.key 2048)
4 Generating RSA private key, 2048 bit long modulus
5 ...............+++
6 ......................................................+++
7 e is 65537 (0x10001)
    2、生成證書簽署請求  
    # openssl req -new -key /etc/httpd/ssl/httpd.key -out /etc/httpd/ssl/httpd.csr
 1 # openssl req -new -key /etc/httpd/ssl/httpd.key -out /etc/httpd/ssl/httpd.csr 
 2 You are about to be asked to enter information that will be incorporated 
 3 into your certificate request. 
 4 What you are about to enter is what is called a Distinguished Name or a DN. 
 5 There are quite a few fields but you can leave some blank 
 6 For some fields there will be a default value, 
 7 If you enter '.', the field will be left blank. 
 8 ----- 
 9 Country Name (2 letter code) [XX]:cn
 10 State or Province Name (full name) []:hn
 11 Locality Name (eg, city) [Default City]:zz
 12 Organization Name (eg, company) [Default Company Ltd]:luo
 13 Organizational Unit Name (eg, section) []:tech
 14 Common Name (eg, your name or your server's hostname) []:test19.magedu.com
 15 Email Address []:
 16 
 17 Please enter the following 'extra' attributes
 18 to be sent with your certificate request
 19 A challenge password []:
 20 An optional company name []:
    3、把簽署請求文件發送給CA服務  
    # scp  httpd.csr UserName@IP:/path

(二) CA簽署證書

1、驗正證書中的信息;  
    2、簽署證書  
    # openssl ca -in /path/to/somefile.csr -out /path/to/somefile.crt -days N
 1 # openssl ca -in /etc/httpd/ssl/httpd.csr -out /etc/httpd/ssl/httpd.crt -days 300 
 2 Using configuration from /etc/pki/tls/openssl.cnf 3 Check that the request matches the signature 
 4 Signature ok 
 5 Certificate Details: 
 6         Serial Number: 1 (0x1) 
 7         Validity 
 8             Not Before: Aug  1 07:51:51 2014 GMT 
 9             Not After : May 28 07:51:51 2015 GMT
 10         Subject:
 11             countryName               = cn
 12             stateOrProvinceName       = hn
 13             organizationName          = luo
 14             organizationalUnitName    = tech
 15             commonName                = test19.magedu.com
 16         X509v3 extensions:
 17             X509v3 Basic Constraints: 
 18                 CA:FALSE
 19             Netscape Comment: 
 20                 OpenSSL Generated Certificate
 21             X509v3 Subject Key Identifier: 
 22                 CC:E6:26:6D:B1:EB:23:F6:7D:2E:47:82:3D:3D:C4:02:76:6C:31:DE
 23             X509v3 Authority Key Identifier: 
 24                 keyid:26:E7:D9:94:88:D4:2F:88:D2:AF:2C:C1:9A:B9:26:5E:D9:F1:E2:62
 25 
 26 Certificate is to be certified until May 28 07:51:51 2015 GMT (300 days)
 27 Sign the certificate? [y/n]:y
 28 
 29 
 30 1 out of 1 certificate requests certified, commit? [y/n]y
 31 Write out database with 1 new entries
 32 Data Base Updated
    3、發送給請求者;
1 [root@stu19 pki]# ls /etc/httpd/ssl/httpd.
2 httpd.crt  httpd.csr  httpd.key

原創文章,作者:N21_ Dominic,如若轉載,請注明出處:http://www.www58058.com/47560

(0)
N21_ DominicN21_ Dominic
上一篇 2016-09-19
下一篇 2016-09-19

相關推薦

  • 謹記初心

    謹以此文記錄我從小白成長的心路歷程與技術的成長

    Linux干貨 2018-03-26
  • redis主從復制(1)— 慢查詢導致復制中斷

    redis的異常行為是一件令人頭疼的問題。redis提供的錯誤日志只提供了一些server的運行狀態信息,而沒有server在故障現場的操作日志,比如執行了什么命令,命令操作對象的數據結構信息。如果redis也有mysql的slow-log,那么很多性能和故障問題也很容易處理。1、redis rdb在redis2.8版本以前,redis主從數據復制在生產上存…

    Linux干貨 2016-04-12
  • 第十八周作業

    1.LNMP架構添加Memcached支持,并驗證其緩存結果 Memcache是一個高性能的分布式的內存對象緩存系統,通過在內存里維護一個統一的巨大的hash表,它能夠用來存儲各種格式的數據,包括圖像、視頻、文件以及數據庫檢索的結果等。簡單的說就是將數據調用到內存中,然后從內存中讀取,從而大大提高讀取速度。 Memcached是以守護程序(監聽)方式運行于一…

    2017-07-07
  • Linux網絡管理基礎

    Linux網絡管理基礎 動態路由 Bonding Network Teaming 靜態路由實驗 Linux的網絡管理,了解基本的網絡知識是基礎,除此,要掌握好ifconig命令、ip命令、nmcli命令(CentOS 7),以及涉及到網絡的配置文件。 配置動態路由: 通過守護進程獲取動態路由,安裝quagga包,支持RIP、OSPF、BGP,通過命令vtys…

    Linux干貨 2016-09-09
  • 關于Linux系統無法啟動的問題(1)

                                  &nbsp…

    2017-09-04

評論列表(1條)

  • 馬哥教育
    馬哥教育 2016-09-19 17:56

    寫的很好,畫圖可以更好的記住問題,值得表揚

欧美性久久久久