apache - 如何生成使用 SNI 的自签名证书?
问题描述
好的——我给。我有一个项目要求我做,我想测试它(人们告诉我测试很好)。我正在尝试测试一些监视 SNI 增强证书的路由器逻辑。我可以使用 OpenSSL 生成自签名证书,并且可以构建 Apache 以使用 SNI,但是我如何告诉 OpenSSL 使用 SNI 字符串生成自签名证书?最后,我想要这样的东西:
- 域=disruptix.com
- 子域及其证书 red.disruptix.com、green.disruptix.com、blue.disruptix.com
- 我将为红色、绿色和蓝色生成三个证书,每个证书都有红色、绿色和蓝色的 SNI 字符串。
- 路由器逻辑将嗅探 SNI,寻找红色、绿色或 blue.disruptix.com 并应用适当的流量控制策略。
我知道 SNI 确实不是要使用的东西,但有人告诉我这就是想要的。如何创建这些自签名证书?
解决方案
要创建自签名证书,请为此创建一个目录,然后运行以下命令:
openssl req -newkey rsa:2048 -nodes -keyout key.key -x509 -days 365 -out certificate.crt
上述命令将生成有效期为 365 天的 2048 位 RSA 证书。我不确定 sni 是否有什么特别之处,除了您使用共享 IP 地址。并且,要设置它,使用基于名称的虚拟主机,请查看https://cwiki.apache.org/confluence/display/HTTPD/NameBasedSSLVHostsWithSNI了解更多信息。
基本上是这样配置的:
<VirtualHost 1.2.3.4:80>
ServerAdmin email@example1.com
ServerName example1.com #This says that if the ip is accessed through example1.com, display the document root for example1.com, and take all the config from this virtualhost
DocumentRoot /path/to/document/root/for/example1.com
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerAdmin email@example2.com
ServerName example2.com #This says that if the ip is accessed through example1.com, display the document root for example2.com, and take all the config from this virtualhost
DocumentRoot /path/to/document/root/for/example2.com
</VirtualHost>
推荐阅读
- php - 到达多个文件夹中的控制器
- c# - SetupSet/VerifySet 起订量失败
- javascript - 函数内部的条件渲染
- r - 在 data.table R 中搜索索引
- flutter - 如何拥有动态容器大小
- ios - 从 UID 检索 firebase 信息
- javascript - 如何为模态对话框设置计时器以在按下按钮时出现
- angular - 动态组件中的 Angular ExpressionChangedAfterItHasBeenCheckedError
- php - 如何覆盖循环模板并在添加到特定类别或多个产品的购物车按钮旁边显示数量
- c++ - 这怎么可能隐藏在 C++ 中的函数中?