Maven中的SSL客户端证书

编程入门 行业动态 更新时间:2024-10-06 18:26:20
本文介绍了Maven中的SSL客户端证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用maven-jaxb22-plugin生成类,因此我可以调用用.Net编写的Web服务。通常它工作正常,但这一次,我只能通过HTTPS使用客户端证书访问WSDL(不能通过HTTP获得)。

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 client certificate through HTTPS (not available through HTTP).

我能够使它与SoapUI一起使用。我将客户端证书添加到JKS密钥库中,并将其添加到SoapUI首选项中。然后我通过指定如下所示的URL创建了一个新项目: server/Service ?WSDL 即可。 SoapUI生成了请求模板。我很容易查询Web服务并得到响应。所以这证明了WSDL是可用的并且Web服务正在运行。

I was able to make it work with SoapUI. I added the client certificate into a JKS keystore and added it to the SoapUI preferences. Then I created a new project by specifying the URL which looks like this: server/Service?wsdl. SoapUI generated the request template. I was easily able to query the web service and get a response. So this prove that the WSDL is available and the web service is working.

现在,在我的pom文件中,我正在使用这个插件:

Now, in my pom file, I am using this plugin:

<build> <finalName>MyService</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb22-plugin</artifactId> <version>0.8.3</version> <configuration> <extension>true</extension> <removeOldOutput>true</removeOldOutput> <schemaLanguage>WSDL</schemaLanguage> <verbose>true</verbose> <schemaIncludes> <includeSchema>server/Service?wsdl</includeSchema> </schemaIncludes> </configuration> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build>

如何告诉Maven我的客户证书在哪里?

How can I tell Maven where my client certificate is?

谢谢

推荐答案

你可以使用 Maven属性插件或使用JVM属性提供信任存储位置。

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

在你的 POM 构建/插件部分,添加一个新的插件条目,此示例中密钥库为 YourKeyStore.jks :

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.ssl.trustStore</name> <value>${basedir}/src/test/jmeter/jmeterTrustedKeystore.jks</value> </property> <property> <name>javax.ssl.keyStorePassword</name> <value>changeit</value> </property> </properties> </configuration> </execution> </executions> </plugin> ...

更多推荐

Maven中的SSL客户端证书

本文发布于:2023-11-26 09:35:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633583.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   证书   Maven   SSL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!