3-18 CA认证过程及https 实现方法

18.1  CA  认证流程

18.2  实战:搭建CA认证中心

18.3  实战:使用证书搭建https 


注意   CA  就是公安局

认证中心   CA的功能,证书方法,证书更新,证书撤销和证书验证

CA证书作用,身份认证,   数据的不可否认性

https  箭筒端口  443   

数字证书认证过程:

身份证办理过程    带上户口本   当地派出所    》 签发证书   代你领证书

18.1   数字证书认证过程





18.2   实战:搭建CA认证中心

  18.2.1  安装CA认证中心

1 )[root@xuegod1 ~]# rpm -qf `which openssl`

openssl-1.0.2k-19.el7.x86_64

2  配置一个自己的CA认证中心,生成CA的更证书和私钥,根证书

修改配置文件

[root@xuegod1 ~]# vim /etc/pki/tls/openssl.cnf


18.2.3  生成CA的公钥证书和私钥

[root@xuegod1 ~]# /etc/pki/tls/misc/CA -h

usage: /etc/pki/tls/misc/CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify

  -newcert   新证书

  - newreq    新请求

  -  newreq-nodes    新请求节点

-   newca    新的CA证书

  -  sign   签证

  -   verify   验证

[root@xuegod1 ~]# /etc/pki/tls/misc/CA -newca

CA certificate filename (or enter to create)

Making CA certificate ...   这里直接回车不用等

Generating a 2048 bit RSA private key

......................................................+++

......+++

writing new private key to '/etc/pki/CA/private/./cakey.pem'     输入密码123456

Enter PEM pass phrase:

Verifying - Enter PEM pass phrase:

-----

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [XX]:CN  国家

State or Province Name (full name) []:beijing  城市

Locality Name (eg, city) [Default City]:haidian  地址

Organization Name (eg, company) [Default Company Ltd]:xuegod公司名称

Organizational Unit Name (eg, section) []:IT  行业

Common Name (eg, your name or your server's hostname) []:xuegod1  主机名

Email Address []:1@163.com  邮箱

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:回车

An optional company name []:  回车

Using configuration from /etc/pki/tls/openssl.cnf

Enter pass phrase for /etc/pki/CA/private/./cakey.pem:  输入刚才的密码

Check that the request matches the signature

Signature ok


到此CA认证中心就搭建好了

  18.2.4  查看生成的CA根证书,根证书包含CA公钥

[root@xuegod1 ~]# vim /etc/pki/CA/cacert.pem    公钥信息


私钥信息

[root@xuegod1 ~]# vim /etc/pki/CA/private/cakey.pem


18.3   实战  :使用证书搭建https  

 1 )  安装:httpd  在xuegod2 上安装配置https  步骤

    2  xuegod2  生成请求文件,发给xuegod2  CA认证中心进行签名,xuegod1  下发证书

给xuegod2 

3   把证书和httpd  想结合,实现https  

4 测试https  认证效果

1  )  安装httpd  

      yum   install -y   httpd 

  vim   /etc/httpd/conf/httpd.conf  

  ServerName   的名字修改为

  ServerName   192.168.24.62   :80  

  2  ) 启动   systemctl   start   httpd   

   18.3.2   xuegod2   生成证书请求文件,获得证书

  [root@xuegod2 ~]# openssl genrsa -des3 -out /etc/httpd/conf.d/server.key  

Generating RSA private key, 2048 bit long modulus

.......................................................+++

.................................................................................................+++

e is 65537 (0x10001)

Enter pass phrase for /etc/httpd/conf.d/server.key:  123456 输入密码  ,保护私钥时,使用的加密算法是-des3

Verifying - Enter pass phrase for /etc/httpd/conf.d/server.key:  再次输入密码   

 注意:  有私钥可以退出来公钥,但是公钥不可以退出私钥来,公钥由私钥生成

18.3.3     

[root@xuegod2 ~]# openssl req -new -key /etc/httpd/conf.d/server.key -out /server.csr  

Enter pass phrase for /etc/httpd/conf.d/server.key:

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:beijing   

Locality Name (eg, city) [Default City]:haidian

Organization Name (eg, company) [Default Company Ltd]:xuegod

Organizational Unit Name (eg, section) []:IT

Common Name (eg, your name or your server's hostname) []:xuegod2

Email Address []:1@163.com

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:直接回车

An optional company name []:  直接回车

常识  是通过私钥可以推出公钥的,通过公钥不可以退出私钥的

18.3.4    将证书请求文件发给CA  服务器 

[root@xuegod2 ~]# scp /server.csr 192.168.24.68:/tmp/

root@192.168.24.68's password:

server.csr

18.3.5   请求证书签证   在68的服务器上

openssl ca -keyfile /etc/pki/CA/private/cakey.pem -cert /etc/pki/CA/cacert.pem -in /tmp/server.csr -out /server.crt

[root@xuegod1 ~]# scp /server.crt 192.168.24.62:/

The authenticity of host '192.168.24.62 (192.168.24.62)' can't be established.

ECDSA key fingerprint is SHA256:KCQGkofX/06SKU9fF3O3RyYIiT/kqph9EUuCMg7JeY0.

ECDSA key fingerprint is MD5:d4:92:5b:85:3c:31:dc:69:ae:bb:f2:63:35:13:64:60.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.24.62' (ECDSA) to the list of known hosts.

root@192.168.24.62's password:

server.crt   


yum -y install mod_ssl

复制证书

[root@xuegod2 ~]# cp /server.crt  /etc/httpd/conf.d/

[root@xuegod2 ~]#

[root@xuegod2 ~]# vim /etc/httpd/conf.d/ssl.conf



[root@xuegod2 ~]# systemctl start httpd

Enter SSL pass phrase for 192.168.24.62:443 (RSA) : ******   输入我们要保护的密码

监听的端口为443

 


  
使用浏览器测试

加入https://192.168.24.62  

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,539评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,594评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,871评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,963评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,984评论 6 393
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,763评论 1 307
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,468评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,357评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,850评论 1 317
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,002评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,144评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,823评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,483评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,026评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,150评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,415评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,092评论 2 355