Java Spring tool suite- SunCertPathBuilderException: unable to find valid certification path to requested target
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50764343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring tool suite- SunCertPathBuilderException: unable to find valid certification path to requested target
提问by shivam gupta
I am working on STS and while creating a new spring-boot project, it shows following error:
I am working on STS and while creating a new spring-boot project, it shows following error:
SunCertPathBuilderException: unable to find valid certification path to requested target
since it access https://start.spring.ioas a service URL.
since it access https://start.spring.ioas a service URL.
I am working in a corporate network and they have their own certificates and security rules. I looked into web but could not find any clear solution for STS. How should I add certification path in STS for given URL. Any help is appreciated.
I am working in a corporate network and they have their own certificates and security rules. I looked into web but could not find any clear solution for STS. How should I add certification path in STS for given URL. Any help is appreciated.
采纳答案by Zack Dawood
Try httpinstead of httpsin the URL http://start.spring.io
Try httpinstead of httpsin the URL http://start.spring.io
The following error will be resolved "SunCertPathBuilderException: unable to find valid certification path to requested target"
The following error will be resolved "SunCertPathBuilderException: unable to find valid certification path to requested target"
回答by Strelok
The simplest solution is to install your corporate certificate into the cacerts
keystore of the JDK.
The simplest solution is to install your corporate certificate into the cacerts
keystore of the JDK.
<JAVA_HOME>/bin/keytool -import -alias CorpProxy -keystore <JAVA_HOME>/jre/lib/security/cacerts -file your_corp_cert.crt
You will be prompted for the keystore password which is changeit
by default.
You will be prompted for the keystore password which is changeit
by default.
回答by sundar.sat84
I encountered the same problem and tried this: Window -> Preferences -> Network Connections Change mode to Manual
I encountered the same problem and tried this: Window -> Preferences -> Network Connections Change mode to Manual
It works fine now.
It works fine now.
回答by PruthvirajSinh Solanki
In the case if none of above work, try below steps. It works fine for me as I was also working under corporate network, had same issue.
In the case if none of above work, try below steps. It works fine for me as I was also working under corporate network, had same issue.
- Close STS tool if open.
- Locate STS.ini file (mostly where you have installed STS tool and have STS.exe)
Edit STS.ini. Add following two line at the bottom (Use your JDK location, below one is just a sample)
-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk1.8.0_20\jre\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit
Save STS.ini and restart the STS.exe.
- Close STS tool if open.
- Locate STS.ini file (mostly where you have installed STS tool and have STS.exe)
Edit STS.ini. Add following two line at the bottom (Use your JDK location, below one is just a sample)
-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk1.8.0_20\jre\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit
Save STS.ini and restart the STS.exe.
It works in my case. Thank you.
It works in my case. Thank you.
回答by blpvivek
Adding below to eclipse.ini
Adding below to eclipse.ini
-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk1.8.0_20\jre\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit
worked for me.
worked for me.
回答by user2125853
It would seem like the http now gets redirected to https. So changing https to http may not work. I am barely familiar with digital certificates. However, I have simply listed what I had to do to get it to work for me. This is perhaps what @Strelok has suggested.
It would seem like the http now gets redirected to https. So changing https to http may not work. I am barely familiar with digital certificates. However, I have simply listed what I had to do to get it to work for me. This is perhaps what @Strelok has suggested.
I am on Windows 10 and JDK 1.8.0_144 64bit. I am also behind a corporate proxy. I did the following to get it to work for me. If you are in a similar situation it may work for you.
I am on Windows 10 and JDK 1.8.0_144 64bit. I am also behind a corporate proxy. I did the following to get it to work for me. If you are in a similar situation it may work for you.
Export the corporate certificate (There may be other easier ways of doing this)
Export the corporate certificate (There may be other easier ways of doing this)
- On Chrome, I went to https://start.spring.io
- On the location bar clicked on the 'Lock' symbol next to https.
- Selected 'Certificate(Valid)' on the ensuing pop-up.
- On the resulting dialog box, clicked on the 'Certificate Path' tab, from under certificate path tree selected the root node, and then clicked on 'View Certificate'
- On the resulting dialog box, clicked on the 'Details' tab and then clicked on 'Copy to File'
- This brings up the 'Export wizard', clicked on 'Next'.
- Left the certificate format to default 'DER encoded..', clicked on 'Next'.
- Provided file name (.cer extension) for the certificate.
- Clicked Finish.
- On Chrome, I went to https://start.spring.io
- On the location bar clicked on the 'Lock' symbol next to https.
- Selected 'Certificate(Valid)' on the ensuing pop-up.
- On the resulting dialog box, clicked on the 'Certificate Path' tab, from under certificate path tree selected the root node, and then clicked on 'View Certificate'
- On the resulting dialog box, clicked on the 'Details' tab and then clicked on 'Copy to File'
- This brings up the 'Export wizard', clicked on 'Next'.
- Left the certificate format to default 'DER encoded..', clicked on 'Next'.
- Provided file name (.cer extension) for the certificate.
- Clicked Finish.
The above steps exported a certificate to a file that I imported into truststore (cacerts).
The above steps exported a certificate to a file that I imported into truststore (cacerts).
To import
To import
- Opened a 'Command' prompt as Administrator to import the certificate
- Went to bin directory of Java installation (this step is not needed if jre/bin is in your path)
Ran the following:
C:\Program Files\Java\jre1.8.0_144\bin>keytool -importcert -alias your-alias -keystore "C:\Program Files\Java\jre1.8.0_144\lib\security\cacerts" -storepass changeit -file C:\certificate-file-location\saved-certificate-file.cer
- Opened a 'Command' prompt as Administrator to import the certificate
- Went to bin directory of Java installation (this step is not needed if jre/bin is in your path)
Ran the following:
C:\Program Files\Java\jre1.8.0_144\bin>keytool -importcert -alias your-alias -keystore "C:\Program Files\Java\jre1.8.0_144\lib\security\cacerts" -storepass changeit -file C:\certificate-file-location\saved-certificate-file.cer
(Substitute your java location, certificate file location and certificate file name as appropriate. The 'storepass' should be 'changeit'.)
(Substitute your java location, certificate file location and certificate file name as appropriate. The 'storepass' should be 'changeit'.)
Restarted STS
Restarted STS
回答by harsha kumar Reddy
The best thing to do in this case is open https://start.spring.io/in browser and
The best thing to do in this case is open https://start.spring.io/in browser and
and fill in your project name in Artifact field and your project base package in Group field click on
and fill in your project name in Artifact field and your project base package in Group field click on
Generate project button
Generate project button
that will download your-project-name.zip file into your downloads folder . now extract this file into your sts workspace or anywhere you like .
that will download your-project-name.zip file into your downloads folder . now extract this file into your sts workspace or anywhere you like .
now import the project in STS as Existing maven project
now import the project in STS as Existing maven project
You are done
You are done
回答by an0nh4x0r
I was able to resolve the issue following two steps.
I was able to resolve the issue following two steps.
- Firstly I imported certificate present on https://start.spring.iointo the jdk cacerts.
Atlast I added the path of TrustStore and trustStore password in SpringToolSuite4.ini file.
-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk1.8.0_201\jre\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit
- Firstly I imported certificate present on https://start.spring.iointo the jdk cacerts.
Atlast I added the path of TrustStore and trustStore password in SpringToolSuite4.ini file.
-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk1.8.0_201\jre\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit