马哥教育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

相关推荐

  • Linux系统程序包管理工具-RPM

    一、rpm是什么 RPM 是RPM Package Manager(RPM软件包管理器)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是其原始设计理念是开放式的。RPM包管理器(RPM)是一个强大的命令行驱动的包管理系统能够安装、卸载、验证、查询和更新计算机软件包。每个软件包包括存档的文件连同包和它的版本信息,描述等。还有一个库API,允…

    Linux干货 2015-11-19
  • 搭建简单的ftp和http

    搭建简单的ftp和http 我们主要尝试光盘和编译两种方式安装 ftp 首先我们先安装ftp ftp可以用来做文件传输,也可以搭建ftp作为我我们的网络yum源 首先我们要先把镜像连接到我们的Linux中 进入/etc/yum.repos.d/创建一个.repo结尾的文件,在里面配置自己的yum源 [base] baseurl=file:///misc/cd…

    2017-06-15
  • CentOS6.7下关于vsftpd的应用之一(匿名用户/普通用户/虚拟用户)

    1)使用yum安装vsftpd [root@C67-X64-A1 ~]# /etc/init.d/vsftpd start为 vsftpd 启动 vsftpd:           &nbs…

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

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

    2017-06-06
  • 难搞的grep、find练习题

    马哥教育网络班21期-第五周博客作业 1、显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@caicai ~]# grep –color "^[[:space:]]\+" /boot/grub/grub.conf    …

    Linux干货 2016-07-26
  • 程序包管理

    Windows与Linux不兼容 库级别虚拟化: Linux:WINE Windows:Cygwin   程序包管理器: debian:deb,dpt redhat:rpm,rpm   Archlinux Gentoo   获取rpm程序包的途径: 1、系统发行版光盘或官方的服务器 centos镜像: http://mirror…

    Linux干货 2018-01-04

评论列表(1条)

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

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