keytool error: java.lang.Exception: Input not an X.509 certificate

This error occurs while using the KeyTool because the native is using the OpenJDK and the tool needs to use the JDK that comes with Oracle.
1. View the JDK on your current machine:

rpm -qa | grep jdk

The result of the native query is openJDK
2. Uninstall the currently installed OpenJDK using Yum Remove.
3. Download the JDK for Linux on oracle’s official website.
4. Configure the environment variable vim /etc/profile locally and then modify the following:

export JAVA_HOME=/home/test/jdk1.8.0_131 (You need to replace it with your own jdk path.)
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME  CLASSPATH  PATH

5. Reload /etc/profile:

source /etc/profile

6. Review the JDK on the current machine and configure it.
7, re-use the keytool command, successful.

Read More: