馬哥教育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 13:47
下一篇 2016-09-19 13:47

相關推薦

  • 正則表達式及文本處理

    正則表達式及文本處理 通俗點說,正則表達式就是處理字符串的方法,更加快速簡潔的代表各個要求參數,一般用于描述字符排列和匹配模式的一種語法規則,通過正則表達式一些特殊符號的輔助,讓用戶輕易的查找、刪除、替換一些字符串的處理程序。( ps:正則表達式和通配符不一樣,通配符代表的是bash接口的一個功能,但正則表達式是一種字符串處理的表達方式,兩者一定要分清楚。)…

    2017-06-11
  • 第一周作業

    描述計算機的組成及其功能。 由馮~諾伊曼提出計算機體系結構,計算機主要由控制器、運算器、存儲器、輸入設備、輸出設備五大硬件組成。 控制器(Controller):是整個計算機的中樞神經,其功能是對程序規定的控制信息進行解釋,根據其要求進行控制,調度程序、數據、地址,協調計算機各部分工作及內存與外設的訪問等。 運算器(Datapath):運算器的功能是對數據進…

    Linux干貨 2017-02-07
  • 第一周作業

    一·計算機組成及其功能     計算機由硬件和軟件組成,他們構成計算機系統 硬件:構成計算機的物理裝置包括中央控制器、存儲器、輸入設備、輸出設備。 中央控制器(CPU):由控制器、運算器、寄存器和緩存組成。cpu的主頻越高和緩存越大性能越好。主頻是中央處理器時鐘的頻率,通常以兆赫茲(MHZ)為單位。緩存:可以進行高速數…

    Linux干貨 2016-12-01
  • linux常用命令實戰練習–第一周作業

    1、使用date命令,顯示前10天的年月日,顯示后20天的年月日。 [root@chen ~]# date  Fri Jul 22 20:26:02 CST 2016 [root@chen ~]# date -d -10day &…

    Linux干貨 2016-07-22
  • 文本處理工具之sed

                         文本處理工具之sed 一 、sed的簡介    1、Stream EDitor…

    2017-05-01
  • N26-博客作業-week11

    1、詳細描述一次加密通訊的過程,結合圖示最佳。 加密過程 1、先用單向加密算法計算出數據的特征碼 2、私鑰加密特征碼,并將結果附加在數據之后 3、生成一個臨時的對稱密鑰,并使用對稱密鑰加密整段數據 4、獲取對方的公鑰,使用該公鑰加密之前生成的臨時對稱密鑰,并附加在數據之后 5、將所有數據發送給對方解密過程 1、先使用私鑰解密加密的對稱密鑰 2、用對稱密鑰解密…

    2017-04-18

評論列表(1條)

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

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

欧美性久久久久