马哥教育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)
N21_ DominicN21_ Dominic
上一篇 2016-09-19 13:47
下一篇 2016-09-19 13:47

相关推荐

  • Lvm基本应用,扩展及缩减实现

    什么是LVM LVM是Logical Volume Manager的简写。其是Linux环境下对磁盘分区进行管理的一种机制。LVM由Heinz Mauelshagen在Linux 2.4内核上实现。其主要作用是在不损坏磁盘数据的情况下对磁盘空间进行增加,缩减。LVM的做法是将几块物理硬盘通过软件的方式组合成一块空间相对大的Volume Group,简称VG,…

    Linux干货 2016-09-08
  • vsftpd相关应用解析

    FTP(File Transfer Protocol)文件传输协议 FTP 是 TCP/IP 协议组中的协议之一。该协议是Internet文件传送的基础,它由一系列规格说明文档组成,目标是提高文件的共享性,提供非直接使用远程计算机,使存储介质对用户透明和可靠高效地传送数据。简单的说,FTP就是完成两台计算机之间的拷贝,从远程计算机拷贝文件至自己的计算机上,称…

    2017-06-06
  • iptables简单概念..

    iptables: 包过滤型的防火墙 Firewall:防火墙,隔离工具;工作于主机或网络边缘,对于进出本主机或本网络的报文根据事先定义的检查规则作匹配检测,对于能够被规则匹配到的报文作出相应处理的组件;    主机防火墙     网络防火墙   &…

    Linux干货 2017-06-19
  • iptables之froward

    先克隆一台centos服务器添加虚拟网卡 同时两个服务器配上host only的网卡 echo 1 > /proc/sys/net/ipv4/ip_forward打开网卡间转发 有回包 但是没有10.0.0.3还是没有ping通原因是192.168.68.134 的网关指向了192.168.68.2 而不是192.168.68.144添加一条指向192…

    2017-11-12
  • httpd配置支持https

    httpd配置支持https 建一台私有CA 配置httpd支持ssl协议以及使用证书 测试基于https访问的相应主机 rpm包安装的httpd https https 超文本传输安全协议(英语:Hypertext Transfer Protocol Secure,缩写:HTTPS,也被称为HTTP over TLS,HTTP over SSL或HTTP …

    Linux干货 2016-12-21
  • 管理分区和文件系统及挂载设备

    管理分区 列出块设备 lsblk       分区工具fdisk fdisk -l /dev/sdX 查看硬盘分区信息 CentOS7: fdisk -l /dev/sda 默认开启dos及扇区显示模式    开启dos及柱面显示模式:fdisk -c=dos -u=cylinders -l /dev/sda…

    2017-08-26

评论列表(1条)

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

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