leponceau.org

Programming And Stuff, You Know The Thing…

Creating self-signed certificates/keystores on-the-fly using maven

Posted at — Oct 12, 2017
 <plugin>
     <artifactId>maven-antrun-plugin</artifactId>
     <version>1.7</version>
     <executions>
         <execution>
             <phase>process-test-resources</phase>
             <configuration>
                 <tasks>
                     <taskdef resource="net/sf/antcontrib/antcontrib.properties" />
                     <if>
                         <available file="${keystore.location}"/>
                         <then></then>
                         <else>
                             <genkey alias="james" storepass="nosecret" keypass="nosecret"
                             keystore="${keystore.location}"
                             dname="CN=localhost"/>
                         </else>
                     </if>
                 </tasks>
             </configuration>
             <goals>
                 <goal>run</goal>
             </goals>
         </execution>
     </executions>
     <dependencies>
         <dependency>
             <groupId>ant-contrib</groupId>
             <artifactId>ant-contrib</artifactId>
             <version>20020829</version>
         </dependency>
     </dependencies>
 </plugin>