Spring 安全 x.509 身份验证 - 接受基于其颁发者证书颁发机构的证书

Spring security x.509 authentication - accept certificates based on their issuer Certificate Authority

我正在使用 Spring 安全 authenticate using an x.509 certificate,它仅在浏览器密钥库中配置的客户端证书存在于服务器信任库中时才有效。

目前的运作方式:

问题是,如果我从服务器端信任库中删除客户端证书,Firefox 将不再打开此弹出窗口,而只会建立单向 SSL 连接。即使根 CA 证书存在于服务器信任库中。

我想要的:

我也对 Internet 上的两个资源很感兴趣。在 Baeldung 的 this tutorial 中,它说所有客户端证书必须存储在服务器信任库中才能使 X.509 身份验证工作(这证实了我的经验)。

You must remember that for each user that should be verified by the server, its own certificate needs to be installed in the configured truststore. For small applications with only a few clients, this may perhaps be practicable, with an increasing number of clients it may lead to complex key-management for users.

然而,this tutorial by @robinhowlett 表示

The client will present its certificate in its keystore to the server, and the server will validate the client certificate’s chain using the CA certificate in the server’s truststore.

这基本上是我想要实现的,但我做不到。

底线:是否有人设法在服务器信任库中存储一个或多个根 CA 证书并使用这些根 CA 颁发的客户端证书通过 X.509 进行身份验证Spring 安全性中的相互 SSL 握手?

我正在使用 Spring Boot 1.5.2.RELEASE (spring-security-web 4.2.2.RELEASE)。我已经使用 Firefox 53 测试了我的工作 SSL 身份验证。

我发现了我的问题 - 我正在修改信任库(删除客户端证书并仅保留 CA 证书),而服务器已启动(Tomcat,在我的例子中)。但是信任库保存在内存中,并且只在 JVM 初始化时读取一次(详情 on this ServerFault post)。因此 Tomcat.

不会在运行时读取信任库更改

所以答案很简单:是的,如果信任库中只有 CA 证书,在 SSL 握手期间,服务器会与浏览器通信,它需要由受信任的 CA 颁发的客户端证书,然后浏览器会提示用户 select 由受信任的 CA 颁发的证书(如果浏览器密钥库中存在此类证书)。

但是,如果在服务器启动时将 CA 动态添加到服务器信任库 运行,则不会检测到它。新的CA只有在服务器重启后才能被识别(并且JVM被重新初始化)。