马哥教育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.178linux.com/47560

(0)
上一篇 2016-09-19 13:47
下一篇 2016-09-19 13:47

相关推荐

  • 网络基础命令与配置文件地址

    centos6查看网卡dmesg | grep -i ethethtool -i eth0卸载网卡驱动modprobe -r e1000rmmod e1000装载网卡驱动modprobe e1000网络配置,静态指定system-config-network-tui 字符界面式网络配置ip addr add IP地址 via 网关IP地址动态分配在/etc/…

    2017-09-09
  • Linux下常用压缩工具总结

    gzip: 1)只能针对普通文件进行压缩,对文件夹、符号链接无效。 2)如果想对多个文件一起压缩并打包,gzip是无法办到的,需要结合tar进行 [root@mysql-master databackup]# ll 总用量 32 drwx—— 2 root root 4096&nb…

    Linux干货 2016-12-05
  • 马哥教育网络班22期+第4周课程练习

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。   cp -r /etc/skel /home/tuser1    chmod -R go=— /home/tuser1 2、编辑/etc/group文件,添加组hadoo…

    Linux干货 2016-09-19
  • GOPS 2016全球运维大会 上海站

    GOPS 2016全球运维大会 • 上海站已经圆满落幕,最新GOPS大会推荐:GOPS2017全球运维大会 • 深圳站 基本信息: GOPS2017全球运维大会 • 深圳站 时间:2017-04-21 08:00:00 至 2017-04-22 18:00:00结束 地点:深圳    会议规模:5000人 会议详情:http://www….

    系统运维 2016-09-07
  • 初学Linux之用户、组和权限

    1、用户和组管理命令 
    2、理解文件权限和默认权限 
    3、设置文件权限
    4、特殊权限 
    5、ACL

    2017-12-08
  • Linux初识

    Linux

    2018-03-07

评论列表(1条)

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

    写的很好,画图可以更好的记住问题,值得表扬