I have a web client to call some REST API which is running over https using Vertx WebClient. The response received from the server is in encrypted format. How to decrypt it automatically? Do I need to install SSL certificates of the server in my JVM to do this? I have a similar client written using Jersey rest client library which is automatically decrypting the response without installing the any certificates in JVM where I can see the proper response from the same API
this.client.post(“some/url”)
.putHeader("Content-Type", "application/json; charset=UTF-8")
.putHeader("Content-Length", "10")
.putHeader("User-Agent", "Dalvik/1.6.0 (Linux; U; Android 4.4.4; SAMSUNG-SM-N900A Build/KTU84P)")
.putHeader("Connection", "Keep-Alive")
.putHeader("Accept-Encoding", "gzip")
.sendBuffer(Buffer.buffer("abcde"))
.subscribe().with(r -> {
System.out.println(String.format("Subscribe: code:%d body:%s",r.statusCode(), r.bodyAsString()));
});
The above code is printing decrypted message on console something like below.
:��mo���B�����%�Ʋ�(�e�������mФ b�ؠ��s9�^J�d�@g,s�gν��������z�}��~��Hy6[><�����������r����ο|]�=���)'�u�����{��_��w�����ϸ<��/�>N��������+�ݗۯ��s�wy�����f��z����"$�����o��ý���h��n��V��b��ۉ�=ܟ?���tRF�M�~��c���C�G�B�����u��n�~~����6����G�ZH�� �I�����H8������c��/6���հ�㣦`�V�ZN,���[��a���SQ��Pla���
Instead of adding theAccept-Encoding
header manually, configure the client so that compression handling is enabled:
WebClientOptions options = new WebClientOptions().setTryUseCompression(true);