【问题标题】:How to generate a self-signed certificate that uses SNI?如何生成使用 SNI 的自签名证书?
【发布时间】:2020-03-01 21:43:19
【问题描述】:

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

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

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

【问题讨论】:

    标签: apache openssl sni


    【解决方案1】:

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

    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>
    

    【讨论】:

      猜你喜欢
      • 2019-04-18
      • 2016-12-04
      • 1970-01-01
      相关资源
      最近更新 更多