Brief examples on how to use the goals. For full documentation, click here.
For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>changeAlias</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
<destalias>new_alias</destalias>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>changeKeyPassword</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<alias>foo_alias</alias>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<newPassword>newpassword</newPassword>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>changeStorePassword</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<newPassword>newPassword</newPassword>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>deleteAlias</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<alias>foo_alias</alias>
<keypass>keypass</keypass>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>exportCertificate</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<alias>foo_alias</alias>
<keypass>keypass</keypass>
<file>/path/to/exportFile</file>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>generateCertificate</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<dname>cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US</dname>
<keypass>keypass</keypass>
<storepass>storepass</storepass>
<alias>foo_alias</alias>
<inFile>/path/to/certificateRequest</inFile>
<outFile>/path/to/exportCertificate</outFile>
<sigalg>SHA1withDSA</sigalg>
<ext></ext>
<validity>100</validity>
<startdate>2012/01/01</startdate>
</configuration>
</plugin>
</plugins>
</build>
</project>mvn keytool:generateCertificate -Dkeystore=/path/to/your/keystore -Dstorepass=storepass -Dkeypass=keypass \ -Dalias=foo_alias -DinFile=/path/to/certificateRequest -DoutFile=/path/to/exportCertificate \ -Ddname="cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US" \ -Dsigalg=SHA1withDSA -Dext="" -Dvalidity=100 -Dstartdate="2012/01/0"
For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>generateCertificateRequest</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
<dname>cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US</dname>
<file>/path/to/exportCertificateRequest</file>
<sigalg>SHA1withDSA</sigalg>
</configuration>
</plugin>
</plugins>
</build>
</project>mvn keytool:generateCertificateRequest -Dkeystore=/path/to/your/keystore -Dstorepass=storepass -Dkeypass=keypass \ -Dalias=foo_alias -Dfile=/path/to/exportCertificateRequest -Dsigalg=SHA1withDSA \ -Ddname="cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US" \
For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>generateKeyPair</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
<dname>cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US</dname>
<sigalg>SHA1withDSA</sigalg>
<ext></ext>
<validity>100</validity>
<keyalg>DSA</keyalg>
<keysize>1024</keysize>
</configuration>
</plugin>
</plugins>
</build>
</project>mvn keytool:generateKeyPair -Dkeystore=/path/to/your/keystore -Dstorepass=storepass -Dkeypass=keypass \ -Dalias=foo_alias -Dsigalg=SHA1withDSA -Dext="" -Dvalidity=100 -Dkeyalg=DSA -Dkeysize=1024 \ -Ddname="cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US"
For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>generateSecretKey</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
<keyalg>DES</keyalg>
<keysize>56</keysize>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>importCertificate</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
<file>/path/to/certificate</file>
<trustcacerts>true</trustcacerts>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>list</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<storepass>storepass</storepass>
<keypass>keypass</keypass>
<alias>foo_alias</alias>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>printCertificate</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<file>/path/to/certificate</dname>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>printCertificateRequest</goal>
</goals>
</execution>
<phase>generate-resources</phase>
</executions>
<configuration>
<file>/path/to/certificateRequest</file>
</configuration>
</plugin>
</plugins>
</build>
</project>For the example, we will attach the execution to the generate-resources phase.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>printCRLFile</goal>
</goals>
<phase>generate-resources</phase>
</execution>
</executions>
<configuration>
<file>/path/to/CRLFile</file>
</configuration>
</plugin>
</plugins>
</build>
</project><project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>genkey</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
<dname>cn=www.example.com, ou=None, L=Seattle, ST=Washington, o=ExampleOrg, c=US</dname>
<keypass>keypass</keypass>
<storepass>storepass</storepass>
</configuration>
</plugin>
</plugins>
</build>
</project>Brief examples on how to use the keytool:clean goal.
<project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>/path/to/your/keystore</keystore>
</configuration>
</plugin>
</plugins>
</build>
</project><project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<alias>foo_alias</alias>
<keystore>/path/to/your/keystore</keystore>
<keypass>keypass</keypass>
<storepass>storepass</storepass>
<file>path_to_exported_certfile</file>
</configuration>
</plugin>
</plugins>
</build>
</project><project>
...
<packaging>pom</packaging>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.6-SNAPSHOT>/version>
<executions>
<execution>
<goals>
<goal>import</goal>
</goals>
</execution>
</executions>
<configuration>
<alias>foo_alias</alias>
<keystore>/path/to/your/keystore</keystore>
<keypass>keypass</keypass>
<storepass>storepass</storepass>
<file>path_to_keystore_toimport</file>
</configuration>
</plugin>
</plugins>
</build>
</project>