4

I am working on STS and while creating a new spring-boot project, it shows following errors: I tried two options but it didn't work.

Option-1:

Service URL:https://start.spring.io
Error Message: SunCertPathBuilderException: unable to find valid certification path to requested target
 

I followed below instructions but didn't work

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.
The above steps exported a certificate to a file that I imported into truststore (cacerts).

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_271\bin>keytool -importcert -alias your-alias -keystore "C:\Program Files\Java\jre1.8.0_271\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'.)

Restarted STS

I tried below options also but it didn't work

Updated below properties in STS.ini file and restarted the STS but no use

-Djavax.net.ssl.trustStore=C:\Program Files\Java\jdk\jre1.8.0_271\lib\security\cacerts
-Djava.net.ssl.trustStorePassword=changeit

Option-2:

Service URL:http://start.spring.io
Error Message: JSONException: A JSONObject text must begin with '{' at character 1

Note: I am also behind a corporate proxy.
I tried all network connections options also like: Manual, DIrect and Native no use
Current STS version:3.8.4

venkat
  • 465
  • 3
  • 9
  • I followed all instructions in this link https://stackoverflow.com/questions/50764343/spring-tool-suite-suncertpathbuilderexception-unable-to-find-valid-certificati but no use – venkat Jun 21 '22 at 15:57
  • It looks to me like the trust store where you store the cert into is not the same as the trust store that you specified in the .ini file? – Martin Lippert Jun 22 '22 at 07:56
  • It is same location C:\Program Files\Java\jre1.8.0_271\lib\security\cacerts I forgot to add the version(1.8.0_271) in the Question. I will update that – venkat Jun 22 '22 at 09:24
  • You could try to install a separate JDK11 in your system and configure the IDE to use that to run on (and install the cert into that). Just another idea to see where the underlying problem might be. – Martin Lippert Jun 23 '22 at 11:12
  • I have access to use java-8 only. – venkat Jun 23 '22 at 13:30
  • In case you downloaded and extracted Spring Tools 4 for Eclipse, you at least have a JDK 17 in your installation as well, the distribution comes with an embedded JDK 17 runtime. And you can't run the latest versions of Spring Tools 4 for Eclipse with a JDK8 anyway. So you need to make sure that the cert file ends up in the right JDK that is used to run the IDE. The JDK8 is definitely not the that is used by the IDE. – Martin Lippert Jun 24 '22 at 13:17
  • I haven't tried the -Djavax.net.ssl.trustStore property myself yet, so I don't know if that will help. Step 1 would be to verify that the cert ended up in that trust store correctly. Step 2 would be to verify that the JDK that is used to run the IDE actually uses that trust store. – Martin Lippert Jun 24 '22 at 13:18
  • I am using STS 3.8.4 version. I am able to access the spring initializr website through browser – venkat Jun 24 '22 at 13:36
  • I see, you are using an older version that still works on JDK 1.8... :-) I would recommend to follow the steps that I described above to get a better understanding of where the problem might be. And trying the same with a newer version might be a good additional check to see where the problem might come from. – Martin Lippert Jun 29 '22 at 13:22

1 Answers1

0

Please read this announcement from spring team here.

As you mention in your question

Current STS version:3.8.4

But according to the announcement they are dropping maintenance and support for older versions of spring tool suite (3.x) and currently only supporting version 4.x

If you are using eclipse as platform for suite it might be that you use a new version of eclipse that is not compatible with spring tools suite 3.x

So you need to upgrade to this version if you wish to work with tools suite from now on.

Panagiotis Bougioukos
  • 15,955
  • 2
  • 30
  • 47