本文介绍了使用truststore的java ssl连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个连接到https网站的Web应用程序。为此,我必须在lib / security文件夹中的cacerts中安装证书。我想创建一个信任库并将其放在应用程序中,并在连接到其他站点时使应用程序引用此信任库,以便在移动应用程序时,证书随之移动。

I have a web application that connects to a https site. For that I have to install the certificate in the cacerts in lib/security folder. I would like to create a truststore and place it within the application and while connecting to the other site make the app refer to this truststore so that when the application is moved the certificates move with it.

我连接到https网站的方式是使用表单帖子。我该怎么做呢此外,在执行表单发布而不是使用HttpsURLConnection时,如何配置以查看自定义信任库而不是cacerts。

The way I connect to the https site is using a form post. How do I go about doing this. Also, when doing a form post rather than using a HttpsURLConnection, how to configure to look into custom truststore instead of cacerts.

推荐答案

最简单的方法是在启动java进程时设置系统属性: -Djavax.net .ssl.trustStore = ...

The easiest way is to set a system property when launching the java process: -Djavax.net.ssl.trustStore=...

默认的TrustManager使用它,如

This is used by the default TrustManager, as described in http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#X509TrustManager

或者,按照同一文档下一段所述覆盖TrustManager。

Alternatively, override the TrustManager as described in the next paragraph in the same document.

这篇关于使用truststore的java ssl连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 21:05