当前位置: 首页 > news >正文

https创建证书

需要下载httpd模块:yum install httpd -y

前提需要先搭建一个虚拟主机来测试证书创建的效果,以下面www.hehe.com为例,可以参考创建:

[root@localhost conf.d]# vim vhost.conf 
<directory /www>
allowoverride none
require all granted
</directory><virtualhost 192.168.54.131:443> #端口要改为443
documentroot /www/hehe
servername www.hehe.com
alias /hehe /usr/local/mysecret #目录别名
</virtualhost>

虚拟主机创建完成后,再去创建对应的目录和文件,以及写入网页的内容:

[root@localhost conf.d]# mkdir /www/hehe
[root@localhost conf.d]# echo "hehe" >/www/hehe/index.html

在虚拟机本地解析和Windows本地解析文件中添加这条域名解析(虚拟机在/etc/hosts ,Windows在C:\Windows\System32\drivers\etc):
192.168.54.131 www.hehe.com

我们可以给www.hehe.com创建证书,具体创建证书步骤如下:

1.下载mod_ssl模块

[root@localhost conf.d]# yum install -y mod_ssl


2.生成密钥

[root@localhost certs]# openssl genrsa > jiami.key


3.移动密钥到/etc/pki/tls/private/

[root@localhost certs]# mv jiami.key ../private/


4.返回到certs目录下创建证书

[root@localhost certs]# openssl req -utf8 -new -key ../private/jiami.key -x509 -days 100 -out jiami.crt
Country Name (2 letter code) [XX]:86 #证书的地区:86 中国
State or Province Name (full name) []:rhce 
Locality Name (eg, city) [Default City]:shaaxi 
Organization Name (eg, company) [Default Company Ltd]:xi'an #组织
Organizational Unit Name (eg, section) []:peihua #组织单位
Common Name (eg, your name or your server's hostname) []:www.hehe.com #给证书的域名
Email Address []:anmin@hehe.com #邮箱


5.修改ssh.conf配置文件,内容如下:

[root@localhost certs]# vim /etc/httpd/conf.d/ssl.conf
#将密钥文件的目录改一下
SSLCertificateFile /etc/pki/tls/certs/jiami.crt
SSLCertificateKeyFile /etc/pki/tls/private/jiami.key

注意:在配置文件中找到这两行修改一下就行,不用修改其他的内容
 

6.关闭防火墙,重启服务

[root@localhost certs]# systemctl stop firewall.server
[root@localhost certs]# systemctl restart httpd


7.浏览器访问,查看证书

https://www.hehe.com/



8.如果要显示hehe页面内容,需要单独为这个虚拟主机配置,如下:

[root@localhost conf.d]# vim vhost.conf 
<directory /www>
allowoverride none
require all granted
</directory><virtualhost 192.168.54.131:443> #端口要改为443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/jiami.crt
SSLCertificateKeyFile /etc/pki/tls/private/jiami.key
documentroot /www/hehe
servername www.hehe.com
alias /hehe /usr/local/mysecret
</virtualhost>


重启服务就可以了(systemctl restart)

http://www.lryc.cn/news/395960.html

相关文章:

  • C++ 是否变得比 C 更流行了?
  • Redis-Jedis连接池\RedisTemplate\StringRedisTemplate
  • Obsidian 文档编辑器
  • Spring Boot项目中JPA操作视图会改变原表吗?
  • C++之goto陈述
  • ChatGPT提问提示指南PDF下载经典分享推荐书籍
  • 架构设计(2)云原生架构与实例部署
  • 《UDS协议从入门到精通》系列——图解0x84:安全数据传输
  • AFT:Attention Free Transformer论文笔记
  • Linux grep技巧 结合awk查询
  • 关于Qt模型插入最后一行数据中存在未填满的项,点击导致崩溃的解决办法
  • Interpretability 与 Explainability 机器学习
  • Vue3项目如何使用npm link本地测试组件库
  • 后端之路——阿里云OSS云存储
  • 大模型/NLP/算法面试题总结2——transformer流程//多头//clip//对比学习//对比学习损失函数
  • 【atcoder】习题——位元枚举
  • 世界人工智能大会 | 江行智能大模型解决方案入选“AI赋能新型工业化创新应用优秀案例”
  • css浮动及清除浮动副作用的三种解决方法
  • 图像类别生成数字标签
  • 【Python】已解决:SyntaxError: invalid character in identifier
  • RDNet实战:使用RDNet实现图像分类任务(一)
  • Java小白入门到实战应用教程-介绍篇
  • python脚本“文档”撰写——“诱骗”ai撰写“火火的动态”python“自动”脚本文档
  • 若依 / ruoyi-ui:执行yarn dev 报错 esnext.set.difference.v2.js in ./src/utils/index.js
  • 移动端Vant-list的二次封装,查询参数重置
  • SMU Summer 2024 Contest Round 2
  • Qt:11.输入类控件(QLineEdit-单行文本输入控件、QTextEdit-多行文本输入控件、QComboBox-下拉列表的控件)
  • Qt 音频编程实战项目
  • C#委托事件的实现
  • Java策略模式在动态数据验证中的应用