DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Unleashing the Power of Microservices With Spring Cloud
  • Using Spring Cloud Gateway and Discovery Service for Seamless Request Routing
  • Optimizing Cloud Performance: An In-Depth Guide to Cloud Performance Testing and its Benefits
  • Microservices Discovery With Eureka

Trending

  • How To Verify Database Connection From a Spring Boot Application
  • Building AI Applications With Java and Gradle
  • The Systemic Process of Debugging
  • Memory Management in Java: An Introduction
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Resolve PKIX Path Building Failed in Spring Cloud Server

Resolve PKIX Path Building Failed in Spring Cloud Server

The problem was that Java was missing the certificate from a specific website, in this case, http://repo.spring.io.

Ravi Isnab user avatar by
Ravi Isnab
·
Dec. 29, 15 · Tutorial
Like (2)
Save
Tweet
Share
22.69K Views

Join the DZone community and get the full member experience.

Join For Free
I was trying to get spring-cloud-server started on my laptop and I was getting:
Downloaded: http://repo.spring.io/libs-snapshot/org/codehaus/mojo/maven-metadata.xml 
(21 KB at 16.6 KB/sec)  
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml 
  from/to central (https://repo.maven.apache.org/maven2): 
sun.security.validator.ValidatorException: 
    PKIX path building failed: 
    sun.security.provider.certpath.SunCertPathBuilderException: 
    unable to find valid certification path to requested target
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml 
    from/to central (https://repo.maven.apache.org/maven2): 
    sun.security.validator.ValidatorException: 
PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target

Cause:

The issue is I don't have a valid certificate for http://repo.spring.io.

Solution:

Step 1: Get the certificate from the location. In this case it is: http://repo.spring.io.

Here's how:

I used Firefox to browse to the link. On the top left there is a lock icon. Click on it > Click on the right arrow to get to information > Click on More Information > Click on View Certificate > Click on Details > Click on Export and save the certificate on your drive as a file say: Certificate.cer.

** It's important you choose X.509 Certificate (PEM) as the type.

Step 2: Now that you have downloaded the certificate, you need to install the certificate on your machine.

On my machine I did this:

keytool -import -file ~/Downloads/Certificate.cer -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre/lib/security/cacerts

Of course the location of your java's cacerts might be different. To find out the location of cacerts directory, do:

echo $JAVA_HOME

In my case the output of echo $JAVA_HOME was:/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home. Then I just looked for cacerts directory in it and found it to be at: jre/lib/security/cacerts

If you dont't want to install a certificate you can also do below:

export MAVEN_OPTS="$MAVEN_OPTS -Djavax.net.ssl.trustStore=/Users/rhasija/Downloads/Certificate.cer"

This will solve the problem for maven but not necessarily for java.

Summary

The problem was Java was missing the certificate from a specific website, in my case, http://repo.spring.io. So I got the certificate file using Step 1 and then imported the certificate in my machine's java cacerts using keytool as show in Step 2.

Hope you found this information helpful. Please let me know if you have any questions.

References:

  1. https://github.com/escline/InstallCert ↩
  2. http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/ ↩
  3. http://stackoverflow.com/questions/16965453/keytool-certificate-import-gives-erro-message-keystore-was-tampered-with-or ↩
  4. http://stackoverflow.com/questions/11936685/how-to-obtain-the-location-of-cacerts-of-the-default-java-installation ↩
  5. http://stackoverflow.com/questions/25911623/problems-using-maven-and-ssl-behind-proxy 


Spring Cloud

Opinions expressed by DZone contributors are their own.

Related

  • Unleashing the Power of Microservices With Spring Cloud
  • Using Spring Cloud Gateway and Discovery Service for Seamless Request Routing
  • Optimizing Cloud Performance: An In-Depth Guide to Cloud Performance Testing and its Benefits
  • Microservices Discovery With Eureka

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: