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
linux https+apache 证书颁布
最新推荐文章于 2024-09-27 12:05:02 发布
本文详细介绍了HTTPS的工作原理,包括对称秘钥和非对称秘钥的使用,以及在Apache服务器上配置HTTPS的步骤。从生成SSL证书到修改配置文件,每个关键环节都有清晰的解释和命令展示,确保了服务器的传输安全。
摘要由CSDN通过智能技术生成