linux https+apache 证书颁布

本文详细介绍了HTTPS的工作原理,包括对称秘钥和非对称秘钥的使用,以及在Apache服务器上配置HTTPS的步骤。从生成SSL证书到修改配置文件,每个关键环节都有清晰的解释和命令展示,确保了服务器的传输安全。
摘要由CSDN通过智能技术生成

https+apache
http传输  明文   请求报文     响应报文
http+ssl=https   传输的报文加密     传输安全
https
--enable-ssl    #支持ssl协议  实现https的部署
client   192.168.2.10
apache   192.168.2.20
https原理    对称秘钥  和非对称秘钥在https当中都使用到了
客户端和服务端建立连接  服务端会把自己ssl证书(数字签名秘钥这些信息)传递给client,client会先认证这个证书的安全性,client的浏览器当中自带这些机构的信息,便会把服务端发过来的证书和自己自带的认证机构的证书进行对比,对比之后,如果证书是安全的,则使用机构的ca公钥把服务端的公钥解析出来,client拿到服务器的公钥之后,会随机生成对称秘钥,把对称秘钥使用公钥加密传输给服务端,服务端收到加密的对称秘钥,会使用私钥解密,之后传输数据直接使用对称秘钥传递
apache
[root@localhost ~]# yum -y install openssl openssl-devel
生成一对秘钥
[root@localhost ~]# openssl genrsa -out /file.key 2048
Generating RSA private key, 2048 bit long modulus
........+++
.............+++
e is 65537 (0x10001)
genrsa秘钥类型     out /file.key指定存放秘钥的文件
2048  秘钥的长度   
[root@localhost ~]# cat /file.key 
申请文件
[root@localhost ~]# openssl req -new -key /file.key -out /file.csr -days 365  全部回车
req -new  生成新的申请文件
-key /file.key    秘钥存放的文件
-out /file.csr    申请文件存放的目录
-days 365   申请的有效期
#颁发证书
[root@localhost ~]# openssl x509 -req -in /file.csr -signkey /file.key -out /file.crt -days 365
x509  证书的类型 格式
-in /file.csr   申请文件
-signkey /file.key   秘钥文件
-out /file.crt  颁发的证书
-days 365  证书的有效期
https的配置文件
[root@localhost ~]# vim /usr/local/httpd/conf/extra/httpd-ssl.conf
132 SSLEngine on
144 SSLCertificateFile "/usr/local/httpd/conf/file.crt" #证书
154 SSLCertificateKeyFile "/usr/local/httpd/conf/file.key"   #秘钥文件
165 SSLCertificateChainFile "/usr/local/httpd/conf/file.csr"  #申请文件
[root@localhost ~]# cp /file.* /usr/local/httpd/conf/
[root@localhost ~]# vim /usr/local/httpd/conf/httpd.conf
54 Listen 443
134 LoadModule ssl_module modules/mod_ssl.so  #打开支持https的模块
478 #Include conf/extra/httpd-vhosts.conf   #注释虚拟主机
495 Include conf/extra/httpd-ssl.conf   #包含ssl的配置文件
[root@localhost ~]# cd /usr/local/httpd/htdocs/
[root@localhost htdocs]# ls
index.html
[root@localhost htdocs]# cat index.html 
111111
[root@localhost logs]# vim /usr/local/httpd/conf/extra/httpd-ssl.conf
 92 #SSLSessionCache        "shmcb:/usr/local/httpd/logs/ssl_scache(512000)"   #缓存上的配置
[root@localhost logs]# systemctl stop httpd
[root@localhost logs]# systemctl start httpd
client:
[root@localhost ~]# firefox https://192.168.2.20:443

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库从删库到跑路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值