Wednesday, September 25, 2019

httpclient.4.3.x how to view http communication in client application / enable wire logs



if you are consuming any webservice for integration purpose its always useful to have ability to see http communication with server.

 it helps in finding response issue if server is not responding correctly.


if java application is using httpclient 4.3.x version to call APIs, putting following logger gives you details logs from http hand shake to actual request and response body



log4j.logger.org.apache.http.wire=TRACE,eventIntegrator



Thursday, August 20, 2015

AXIS Client Exception:org.apache.axis2.AxisFault: Received fatal alert: handshake_failure

 Exception :



org.apache.axis2.AxisFault: Received fatal alert: handshake_failure

    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)

    at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)

    .

    .

    .

    at java.lang.Thread.run(Thread.java:744)

Caused by: com.ctc.wstx.exc.WstxIOException: Received fatal alert: handshake_failure

    at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:313)

    at org.apache.axiom.om.impl.MTOMXMLStreamWriter.flush(MTOMXMLStreamWriter.java:168)

    .

    .

    .

    at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79)

    ... 120 more

Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)

    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)

    .

    .

    .

    at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311)

    ... 131 more





Cause:


          This exception occurs when their is mismatch between   strength of crystallographic algorithms on Server and client JRE.

resolution:

The stronger cipher is not supported by JAVA by default. On oracle site they provided following reason:

“Due to import regulations in some countries, the Oracle implementation provides a default cryptographic jurisdiction policy file that limits the strength of cryptographic algorithms


If stronger algorithms are needed (for example, AES with 256-bit keys), the JCE Unlimited Strength Jurisdiction Policy Files must be obtained and installed in the JDK/JRE. ”


Reference :

http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html#importlimits



we need to download JCE Unlimited Strength Jurisdiction Policy Files  and install it on client JRE.
Download location:
http://www.oracle.com/technetwork/java/javase/downloads/index.html





 P.S.   Debug SSL communication of JAVA Application you can use following option



 javax.net.debug=all


java http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html