Getting ssl.SSLHandshakeException when using REST client with header but works fine with PostMan

后端 未结 2 1158
一整个雨季
一整个雨季 2020-12-17 02:24

I have an external REST resource with below details:

  1. The URL: abc.com/orders (the domain is with https)
  2. I need to pass User
相关标签:
2条回答
  • 2020-12-17 03:01

    MAN! No need any of above!!! Just pass RestAssured.useRelaxedHTTPSValidation(); before Rest Api code. DONE!`

    0 讨论(0)
  • 2020-12-17 03:12

    These are the instructions to make your program work. Btw, I am on windows, using google chrome.

    You do need a certificate.

    1) First, go to the url (doesn't matter if it's a website or a restful service), let's pick google.com. Right click on the page and click "inspect".

    2) Go to the security tab.

    3) Once, you're there, click "view certificate".

    A window will pop up, with site's certificate's details.

    4) Go to the "certification path" tab. And double click on the certificate that you want from the hierarchy.

    A new window will pop up:

    I chose the root certificate in this case called "Google trust services...", but you can choose a more specific one, like "Google Internet Authority G3". I think the more specific it is, the more security it provides (but I'm not sure).

    5) Go to the "Details" tab and choose your certificate's name:

    6) Click "Copy To File", then choose the name for it and where you want to save it. I saved mine on desktop and named it "test.cer".

    Now you are done exporting the certificate. Next, you want to add it to jvm's truststore.

    1) Look up which JRE your application is running on, for example I have only one JRE on my computer (excluding the one bundled with the JDK). It's located here:

    The target file that stores certificates is cacerts:

    2) Open cmd as administrator and do cd "C:\Program Files\Java\jre-10.0.1\lib\security" (path to cacerts in my case).

    3) Issue the following command:

    keytool -import -storepass changeit -noprompt -alias *alias* -keystore cacerts -trustcacerts -file *path_to_certificate*

    Note that alias can be anything, regardless of what you called your file, as long as it doesn't clash with aliases of other certificates already in the truststore.

    In my case I issue this:

    4) You can now issue this command: keytool -list -keystore cacerts -alias *alias* to make sure your certificate was added. When you issue this command, it will ask you for your password. In step three, the command I gave your had this option: -storepass changeit, so your password will be changeit.

    In my case everything is okay.

    5) Now you can restart your application and it should work. Some people recommend restarting your computer, but I don't know if that's necessary.

    0 讨论(0)
提交回复
热议问题