I'm using keytool-maven-plugin to import alias.cer file into java cacerts store, it works fine. The problem occurs when building the project second time; getting an error because alias.cer file is already added to store. I couldn't see any parameter to fix the problem in plugin. There are 'skip' and 'skipIfExist' parameters. These parameters are not for this purpose; skip disables the plugin, skipIfExist skips if the store already exist.
How could I solve the problem? or do you know alternative plugin for this goal?
I realized that this plugin developed over the java keytool. There isn't any parameter in keytool for the 'skip if certificate is already exist' purpose. Therefore, I've used 'skip' parameter to handle this problem by adding a custom parameter to use while building the project.
<properties>
<cert.skip>true</cert.skip>
</properties>
<plugin>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/keytool-maven-plugin -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<skip>${cert.skip}</skip>
<keystore>${JAVA_HOME}/lib/security/cacerts</keystore>
<storepass>changeit</storepass>
<alias>alias</alias>
<file>${basedir}/src/main/resources/alias.cer</file>
<noprompt>true</noprompt>
</configuration>
</plugin>
Usage: mvn clean install -Dcert.skip=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With