Spring boot Spring Cloud Vault相互TLS身份验证问题
我正在尝试设置一个spring引导应用程序,以便通过TLS与我的Vault服务器通信。我想使用相互证书身份验证。我可以使用TLS设置Vault服务器,并且可以使用CLI使用客户端证书登录到该服务器。但是,spring boot应用程序无法向Vault服务器提供其客户端证书-每次我运行应用程序时,Vault服务器都会打印:Spring boot Spring Cloud Vault相互TLS身份验证问题,spring-boot,ssl,spring-cloud,hashicorp-vault,spring-cloud-vault-config,Spring Boot,Ssl,Spring Cloud,Hashicorp Vault,Spring Cloud Vault Config,我正在尝试设置一个spring引导应用程序,以便通过TLS与我的Vault服务器通信。我想使用相互证书身份验证。我可以使用TLS设置Vault服务器,并且可以使用CLI使用客户端证书登录到该服务器。但是,spring boot应用程序无法向Vault服务器提供其客户端证书-每次我运行应用程序时,Vault服务器都会打印: http: TLS handshake error from 127.0.0.1:33288: tls: client didn't provide a certificate
http: TLS handshake error from 127.0.0.1:33288: tls: client didn't provide a certificate
客户端(我的spring boot应用程序)打印:
这是我的引导。yml
:
spring:
application.name: vault-demo
cloud.vault:
host: localhost
port: 8200
scheme: https
uri: https://localhost:8200
connection-timeout: 5000
read-timeout: 15000
config.order: -10
authentication: CERT
ssl:
trust-store: classpath:keystore.jks
trust-store-password: changeit
key-store: classpath:client-cert.jks
key-store-password: changeit
cert-auth-path: cert
我找不到关于需要在spring.cloud.vault.*
下配置的各种属性的任何文档
Myclient-cert.jks
存储区具有客户端证书和密钥。启用SSL详细日志,我可以看到:
*** ServerHelloDone
Warning: no suitable certificate found - continuing without client authentication
*** Certificate chain
这表示客户端在其信任存储中找到了服务器的证书,但未将客户端的证书发送到服务器
此外,如果我使用curl
发送登录请求,则成功:
curl-k——请求发布\
--证书工作/ca/certs/client.cert.pem\
--密钥工作/ca/private/client.decrypted.key.pem\
--data@payload.json\
https://localhost:8200/v1/auth/cert/login
#返回一个带有新颁发令牌的JSON。
我还尝试使用一个配置类,并将javax.net.ssl.keyStore
和相关属性作为JAVA\u OPTS
传递,但绝对没有区别-vault一直说客户端没有发送证书:
@配置
公共类AppConfig扩展了AbstractVault配置{
@值(“${vault.uri}”)
URI;
@凌驾
公共Vault端点Vault端点(){
返回VaultEndpoint.from(vaultUri);
}
@凌驾
公共客户端身份验证客户端身份验证(){
试一试{
RestTemplate RestTemplate=新RestTemplate();
HttpClientBuilder HttpClientBuilder=HttpClientClient.custom()
.setSSLContext(SSLContext.getDefault())
.useSystemProperties();
restTemplate.setRequestFactory(
新的Http组件客户端Http请求工厂(
httpClientBuilder.build());
返回新的ClientCertificateAuthentication(restTemplate);
}捕获(无算法异常){
抛出新的运行时异常(e);
}
}
}
任何人都可以指出我遗漏了什么/做错了什么?问题是我的Vault配置没有正确指定
tls\u客户端\u ca\u文件
属性。将其设置为根CA证书,一切都正常。也不需要添加AppConfig
类。问题是我的Vault配置没有正确指定tls\u客户端\u ca\u文件
属性。将其设置为根CA证书,一切都正常。也不需要添加AppConfig
类。谷歌快速搜索显示:。正确的值是cert
,您需要将客户端证书和密钥加载到java密钥库中。谢谢@Marc,是的,我应该使用cert
-现在解决了这个问题。该值基本上来自vault auth list
命令的输出。但即使在那之后,结果也是一样的。客户端未发送其证书。为了更清楚,我更新了问题。谷歌快速搜索显示:。正确的值是cert
,您需要将客户端证书和密钥加载到java密钥库中。谢谢@Marc,是的,我应该使用cert
-现在解决了这个问题。该值基本上来自vault auth list
命令的输出。但即使在那之后,结果也是一样的。客户端未发送其证书。为了更清楚,我更新了这个问题。
*** ServerHelloDone
Warning: no suitable certificate found - continuing without client authentication
*** Certificate chain