How to debug SSL issues like InvalidAlgorithmParameterException

SSL issues are common while working on enterprise applications, but their debugging is not easy. Mostly due to not having enough information in logs.

For example, you will get an exception like this for various reasons – I/O error: java.security.NoSuchAlgorithmException: Error constructing implementation.

An exception stack trace may look like this:

com.howtodoinjava.aav.exception.SystemException: I/O error: java.lang.RuntimeException: Unexpected error: 
java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty; nested exception is 
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: 
the trustAnchors parameter must be non-empty
	at com.howtodoinjava.aav.profilemaintenance.dao.impl.ClassName.methodName(ClassName.java:53)
	at com.howtodoinjava.aav.profilemaintenance.dao.impl.ClassName$$FastClassByCGLIB$$581a61ad.invoke()
	at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
	at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at com.howtodoinjava.ecom.common.web.transaction.aop.RequestTraceInterceptor.invoke(RequestTraceInterceptor.java:74)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
	at com.howtodoinjava.aav.profilemaintenance.dao.impl.ClassName$$EnhancerByCGLIB$$233d14.methodName()
	at com.howtodoinjava.aav.profilemaintenance.service.impl.classImpl.methodName(classImpl.java:25)
	at com.howtodoinjava.idp.ptui.web.action.DemoAction.execute(DemoAction.java:97)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)

Problem

Well, as I said that there could be N number of reasons for these error. Some of them may be:

  • file not found
  • wrong password
  • wrong keystore type
  • wrong cert locations

exceptions-notes

Solution

To solve this SSL exception, you must get more information which can tell exactly what is going on. To get that information, enable SSL debug logging by passing javax.net.debug=ssl runtime argument to your server/program.

-Djavax.net.debug=ssl

After passing this flag, your will see extensively detailed logs related to your SSL issue and mostly It will tell you the exact root cause as well.

Happy Learning !!

Was this post helpful?

Join 7000+ Fellow Programmers

Subscribe to get new post notifications, industry updates, best practices, and much more. Directly into your inbox, for free.

Leave a Comment

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.