Reputation: 2030
I need to import two different certificates in my build process. I'm using keytool-maven-plugin, I'm able to import 1 plugin but I'm not able to import 2 different ones.
Here is my pom snippet
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<keystore>${project.build.directory}/client-truststore.jks</keystore>
<storepass>storepass</storepass>
<alias>alias</alias>
<file>ca.pem</file>
<noprompt>true</noprompt>
</configuration>
</plugin>
Thanks in advance.
Upvotes: 2
Views: 4140
Reputation: 9463
Invoking keytool-maven-plugin multiple times has it's problems. That is why there is another open source project meanwhile that aims at solving the issue:
https://github.com/AmadeusITGroup/amadeus-keytool-plugin
From it's website:
The Amadeus Keytool Plugin allows to build java keystores (and truststores) within the Maven build. This per se does not make it unique. But if you need to add multiple certificates, Amadeus Keytool Plugin is still with you.
Upvotes: 0
Reputation: 32028
Few things -
as discussed and inferred above <id>
is something that you are missing in your <execution>
tag
also, if you want to make the alias configurable please use changeAlias
in your execution as -
<goals>
<goal>changeAlias</goal>
</goals>
Source - Keytool Maven Plugin
How to use keytool:changeAlias
specifying parameters on the command line
> mvn keytool:changeAlias -Dkeystore=/path/to/your/keystore > -Dstorepass=storepass -Dkeypass=keypass -Dalias=foo_alias \ -Ddestalias=new_alias
and for different executions you can try to configure different aliases as follows -
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>package</phase>
<id>executionOne</id>
<configuration>
<keystore>${project.build.directory}/client-truststore.jks</keystore>
<storepass>storepass</storepass>
<alias>alias</alias>
<file>ca.pem</file>
<noprompt>true</noprompt>
</configuration>
</execution>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>package</phase>
<id>executionTwo</id>
<!--change this from one above-->
<configuration>
<keystore>${project.build.directory}/client-truststore.jks</keystore>
<storepass>storepass</storepass>
<alias>alias</alias>
<file>ca.pem</file>
<noprompt>true</noprompt>
</configuration>
</execution>
</executions>
Upvotes: 2