2

I'm creating a micro service in Spring Boot which needs to communicate with an existing authentication service.

I have setup the OAuth configuration in Spring Boot, but I'm seeing the following error when it tries to talk to the external authentication service.

Could not fetch user details: class org.springframework.web.client.ResourceAccessException, I/O error on GET request for "https://somedomain.com/profile": sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

This appears to be because the certificate on the remote authentication service isn't valid, so it doesn't like it.

How do I resolve this?

I have tried to use openssl to download the domains certificate, and I've added this to Java's keystore, but that didn't fix the problem.

To grab and install the cert I did the following;

openssl s_client -showcerts -connect somedomain.com:443

keytool -importcert -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/lib/security/cacerts -storepass changeit -file /Users/myuser/Downloads/plplpl.crt

I was asked if I wanted to trust the cert, I selected yes.

SheppardDigital
  • 3,165
  • 8
  • 44
  • 74
  • 1
    *"How do I resolve this?"* Install a valid certificate on the remote authentication service. If that certificate is not issued by a well-known CA, you need to add the root certificate to `cacerts`. – Andreas Feb 19 '19 at 16:39
  • I don't have access to the remote authentication service. – SheppardDigital Feb 19 '19 at 16:42
  • I think the certificate from the server is ok but your client dont "trust" the server. Only for testing: can you disable client validation: https://stackoverflow.com/questions/23504819/how-to-disable-ssl-certificate-checking-with-spring-resttemplate/24491820 – pL4Gu33 Feb 19 '19 at 17:11
  • I added the certificate but still getting same error: valid certificate not found. As answered by @andreas, after adding root certificate, resolved my issue. – tabish Jun 30 '21 at 07:02

0 Answers0