Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't load p12 #3400

Open
gilmith opened this issue May 17, 2024 · 0 comments
Open

Doesn't load p12 #3400

gilmith opened this issue May 17, 2024 · 0 comments

Comments

@gilmith
Copy link

gilmith commented May 17, 2024

Hello,

I'm learning spring cloud and I have a p12 self signed certificate for eureka and configserver in a p12 file in my classpath. The certificate load correctly overwritting the @bean as follow

@Bean public RestTemplateDiscoveryClientOptionalArgs getTrustStoredEurekaClient() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException { RestTemplateDiscoveryClientOptionalArgs args = new RestTemplateDiscoveryClientOptionalArgs(requestFactory); args.setSSLContext(new SSLContextBuilder() .loadTrustMaterial(trustStore.getURL(), trustStorePassword.toCharArray()).build()); args.setHostnameVerifier(NoopHostnameVerifier.INSTANCE); return args; }

@Bean public ConfigServicePropertySourceLocator configServicePropertySourceLocator() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException { ConfigServicePropertySourceLocator configServicePropertySourceLocator = new ConfigServicePropertySourceLocator( configClientProperties); configServicePropertySourceLocator.setRestTemplate(createTemplate()); return configServicePropertySourceLocator; }

But using properties to load the p12 in the http client

spring.cloud.gateway.httpclient.ssl.trust-store=classpath:keystore/springboot.p12
spring.cloud.gateway.httpclient.ssl.trust-store-password=password
spring.cloud.gateway.httpclient.ssl.trust-store-type=pkcs12

don't load the certificate, return "PKIX path building failed:"

But using the pem file of the certificate
spring.cloud.gateway.httpclient.ssl.trusted-x509-certificates=${user.home}${file.separator}certificate.crt

Works correctly.

Please someone have had the same problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant