WildFly 多域和 SSL 证书

WildFly multiple domains and SSL certificates

我有两个不同的域

每个域都有自己的 SSL 证书。

我现在想做的是,将两个域用于同一个 WildFly 实例,支持 SSL。

WildFly 文档指出,我只能引用密钥库中的单个证书。因此,我不能只定义一个 <security-realm> 和一个包含两个证书的密钥库。

因此,我定义了两个不同的<security-realm>。每个域一个。

  <security-realm name="RealmExample1">
                <server-identities>
                    <ssl>
                        <keystore path="example1.jks" keystore-password="secret" />
                    </ssl>
                </server-identities>
                ...
            </security-realm>

  <security-realm name="RealmExample2">
                <server-identities>
                    <ssl>
                        <keystore path="example2.jks" keystore-password="secret2" />
                    </ssl>
                </server-identities>
                ...
            </security-realm>

但是,我无法将两个安全域添加到单个主机。

<server name="default-server">
                <http-listener name="default" socket-binding="http" redirect-socket="https-ext"/>
                <https-listener name="default-ssl" security-realm="UndertowRealm" socket-binding="https"/>
                <host name="default-host" alias="localhost">
                    <filter-ref name="central-basic-auth"/>
                </host>
            </server>

现在,如果我为每个域定义一个服务器,我不能引用相同的 http/https 侦听器绑定,因为端口被阻止。

到目前为止,我找到的唯一解决方案是拥有两个 public IP 地址并定义两个接口,并为每个接口定义一个 http/https 套接字绑定。然后我可以定义两个具有不同别名和不同套接字绑定的服务器。

截至目前,很遗憾,WildFly 不支持 SNI。

还有其他可能的解决方案吗?

虽然这会使您的部署有点复杂,但您是否考虑过将 Apache httpd 放在您的 Wildfly 服务器前面?这并不难,而且它确实支持 SNI。您将不得不为 Apache 更改您的证书,但随后,使用 Apache 虚拟主机,您可以拥有类似:

<VirtualHost _default_:443>
    ServerName www.firstdomain.com
    ProxyPreserveHost on
    ProxyPass / http://localhost:8080/
    ProxyTimeout 360
</VirtualHost>

在第一个虚拟主机文件中和:

<VirtualHost _default_:443>
    ServerName www.seconddomain.com
    ProxyPreserveHost on
    ProxyPass / http://localhost:9080/ # if it is a different instance or
    ProxyPass / http://localhost:8080/app2 # if it the same instance, different webapp
    ProxyTimeout 360
</VirtualHost>

同样,问题是您需要维护另一个进程,并且需要为 Apache 设置 SSL。但是您随后可以使用 Apache 执行 SSL,如果您愿意,还可以执行以下操作:

Header set Content-Security-Policy ...
Header set X-XSS-Protection "1; mode=block"

此设置对我来说在 Tomcat 或 Apache 后面的 Wildfly 上运行良好。

抱歉发布了 necroposting,但有一个更简单的选项 - 只需将多个域添加到一个证书即可。

通配符证书的明显方式。

而且 Let's Encrypt 还允许为一个证书指定多个域。而且效果很好,无需等待免费的通配符证书

sh /root/.acme.sh/acme.sh --issue -d yourdomain.com -d www.yourdomain.com -d more.yourdomain.com -w /opt/wildfly-10.1.0.Final/welcome-content