SSL client certificate in Maven

前端 未结 2 1359
臣服心动
臣服心动 2020-12-02 01:21

I use the \"maven-jaxb22-plugin\" to generate classes so I can call a web service written in .Net. Usually it works fine but this time, I can only access the WSDL using a cl

相关标签:
2条回答
  • 2020-12-02 01:41

    You could use maven propety configuration to setup Java System properties. Be careful to set "keyStore" not "trustStore".

    Also, if you are using a certificate that it's not from a valid CA you have to configure maven.wagon.http.ssl.insecure=true and maven.wagon.http.ssl.allowall=true

    In your case use:

    ..
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <properties>
                    <property>
                        <name>javax.net.ssl.keyStore</name>
                        <value>yourks.jks</value>
                    </property>
                    <property>
                        <name>javax.net.ssl.keyStoreType</name>
                        <value>jks</value>
                    </property>
                    <property>
                        <name>javax.net.ssl.keyStorePassword</name>
                        <value>changeit</value>
                    </property>
                    <property>
                        <name>maven.wagon.http.ssl.insecure</name>
                        <value>true</value>
                    </property>
                    <property>
                        <name>maven.wagon.http.ssl.allowall</name>
                        <value>true</value>
                    </property>
                </properties>
            </configuration>
        </execution>
    </executions>
    ..
    
    0 讨论(0)
  • 2020-12-02 02:05

    You could use the Maven properties plugin or use a JVM property to provide the trust store location.

    In your POM build/plugins section, add a new plugin entry, where the keystore would be YourKeyStore.jks for this example:

    ..
    <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
              <execution>
                <goals>
                  <goal>set-system-properties</goal>
                </goals>
                <configuration>
                  <properties>
                    <property>
                      <name>javax.net.ssl.trustStore</name>
                      <value>${basedir}/src/test/jmeter/jmeterTrustedKeystore.jks</value>
                    </property>
                    <property>
                      <name>javax.net.ssl.keyStorePassword</name>
                      <value>changeit</value>
                    </property>
                  </properties>
                </configuration>
              </execution>
            </executions>
    </plugin>
    ...
    
    0 讨论(0)
提交回复
热议问题