Home > Java > javaTutorial > How to Resolve 'sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path'?

How to Resolve 'sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path'?

Patricia Arquette
Release: 2025-01-02 16:18:39
Original
865 people have browsed it

How to Resolve

Java: sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path to Requested Target

When attempting to download a file from an HTTPS server, you may encounter errors due to certificate issues. The error message "sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" indicates a problem with the client-server authentication.

Ignoring Client-Server Authentication

If you wish to ignore the client-server authentication to bypass this error, here are the steps you can take:

  1. Obtain the Server Certificate: Launch your preferred web browser and navigate to the HTTPS URL. Click on the lock icon in the address bar and select "Certificate." From here, you can export the SSL certificate.
  2. Add the Certificate to JVM's Trust Store:

    • Using JAVA_HOME/jre: Navigate to JAVA_HOME/jre/lib/security/cacerts and use the keytool utility to import the certificate:

      keytool -importcert -alias my-server-cert -trustcacerts -keystore cacerts -file YOUR_EXPORTED_CERTIFICATE
      Copy after login
    • Using -Djavax.net.ssl.trustStore parameter: Run your application with the following parameter:

      -Djavax.net.ssl.trustStore=YOUR_TRUST_STORE_PATH
      Copy after login
  3. Verify Correct JDK/JRE Version: Ensure that you are using the correct JDK/JRE version as this can lead to confusion.

By implementing these steps, you can ignore the client-server authentication and establish a secure connection to the HTTPS server.

The above is the detailed content of How to Resolve 'sun.security.provider.certpath.SunCertPathBuilderException: Unable to Find Valid Certification Path'?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template