如何生成使用SNI的自签名证书?

时间:2020-03-01 21:43:19

标签: apache openssl sni

好的-我给。我有一个被要求做的项目,我想测试一下(人们告诉我测试很好)。我正在尝试测试一些监视SNI增强证书的路由器逻辑。我可以使用OpenSSL生成自签名证书,并且可以将Apache构建为使用SNI,但是如何告诉OpenSSL使用SNI字符串生成自签名证书?最后,我想要这样的东西:

  • Domain = disruptix.com
  • 子域及其证书red.disruptix.com,green.disruptix.com,blue.disruptix.com
  • 我将为红色,绿色和蓝色生成三个证书,每个证书带有红色,绿色和蓝色的SNI字符串。
  • 路由器逻辑将嗅探SNI,寻找红色,绿色或blue.disruptix.com并应用适当的流量控制策略。

我知道SNI确实不是要使用的东西,但有人告诉我这就是需要的东西。如何创建这些自签名证书?

1 个答案:

答案 0 :(得分:0)

要创建自签名证书,请为此创建一个目录,然后运行以下命令:

openssl req -newkey rsa:2048 -nodes -keyout key.key -x509 -days 365 -out certificate.crt

以上命令将生成2048位RSA证书,有效期为365天。除了使用共享IP地址外,我不确定是否有关于sni的任何特殊信息。并且,要进行设置,请使用基于名称的虚拟主机,请查看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>