Documentum Rest 服务 - 信任来自 Java 客户端的 SSL 证书
Documentum Rest Service - Trusting SSL certificate from Java Client
我需要接受来自独立 Java 应用程序(将作为 JAR 捆绑)在 REST Web 服务 URL ( https://:/dctm-rest) 上启用的 SSL 证书。
据我所知,最好的方法是使用 Keytool 创建 KeyStore/TrustStore,从 browser/openssl 下载证书并将其添加到 TrustStore.With 我们正在创建依赖关系,必须有人保留关于为每次更新更新证书。
有人可以指导我通过删除手动依赖来实现这个吗?
您必须将 https://dctm-rest
处的服务器证书包含在您的 JRE(信任库)的白名单中
选项
1) 在 JRE trustore 中包含服务器证书 (jre/lib/security/cacerts
) (不推荐)
要下载服务器证书,请使用浏览器打开站点,右键单击绿色锁,select 'view certificate' 并下载
探索 cacerts 和导入可信证书的最简单方法是使用 GUI 工具,如 portecle (http://portecle.sourceforge.net/)。你也可以使用 keytool
keytool -import -trustcacerts -keystore /opt/java/jre/lib/security/cacerts -alias mycert -noprompt -storepass changeit -file /tmp/examplecert.crt
见How to properly import a selfsigned certificate into Java keystore that is available to all Java applications by default?
2) 使用您自己的信任库 并包含服务器证书(推荐)
System.setProperty ("javax.net.ssl.trustStore", path_to_your_trustore_jks_file);
System.setProperty ("javax.net.ssl.trustStorePassword", "password");
您还可以创建一个 SSLSocketFactory 并在连接之前添加到您的连接或使用静态方法应用于所有连接
HttpsURLConnection.setDefaultSSLSocketFactory(sslFactory);
这是创建套接字工厂的示例
//Load JKS keystore that includes the server certificate or the root
KeyStore keyStore = ...
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(null, tmf.getTrustManagers(), null);
sslFactory = ctx.getSocketFactory();
3) 完全不使用信任库(完全不推荐)
参见(我不会复制解决方案)
我需要接受来自独立 Java 应用程序(将作为 JAR 捆绑)在 REST Web 服务 URL ( https://:/dctm-rest) 上启用的 SSL 证书。
据我所知,最好的方法是使用 Keytool 创建 KeyStore/TrustStore,从 browser/openssl 下载证书并将其添加到 TrustStore.With 我们正在创建依赖关系,必须有人保留关于为每次更新更新证书。
有人可以指导我通过删除手动依赖来实现这个吗?
您必须将 https://dctm-rest
处的服务器证书包含在您的 JRE(信任库)的白名单中
选项
1) 在 JRE trustore 中包含服务器证书 (jre/lib/security/cacerts
) (不推荐)
要下载服务器证书,请使用浏览器打开站点,右键单击绿色锁,select 'view certificate' 并下载
探索 cacerts 和导入可信证书的最简单方法是使用 GUI 工具,如 portecle (http://portecle.sourceforge.net/)。你也可以使用 keytool
keytool -import -trustcacerts -keystore /opt/java/jre/lib/security/cacerts -alias mycert -noprompt -storepass changeit -file /tmp/examplecert.crt
见How to properly import a selfsigned certificate into Java keystore that is available to all Java applications by default?
2) 使用您自己的信任库 并包含服务器证书(推荐)
System.setProperty ("javax.net.ssl.trustStore", path_to_your_trustore_jks_file);
System.setProperty ("javax.net.ssl.trustStorePassword", "password");
您还可以创建一个 SSLSocketFactory 并在连接之前添加到您的连接或使用静态方法应用于所有连接
HttpsURLConnection.setDefaultSSLSocketFactory(sslFactory);
这是创建套接字工厂的示例
//Load JKS keystore that includes the server certificate or the root
KeyStore keyStore = ...
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(null, tmf.getTrustManagers(), null);
sslFactory = ctx.getSocketFactory();
3) 完全不使用信任库(完全不推荐)
参见