gpt4 book ai didi

java - 从 WebSphere 连接到受 SSL 证书保护的 WebService

转载 作者:太空宇宙 更新时间:2023-11-03 15:06:36 29 4
gpt4 key购买 nike

我们有 WAS (Websphere Application Server) 7 网络服务,这是对其他方 SSL 保护的网络服务的某种代理。

当在 WAS 外部使用我们的 Web 服务(客户端)时(例如使用 eclipse),它将毫无问题地连接,但在 WAS 内部则不会。我还创建了使用函数打印其他方 WebService(服务器)wsdl 的测试服务。

public void testSSL() {
URL u;
InputStream is = null;
DataInputStream dis;
String s;

try {

System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
System.setProperty("javax.net.ssl.keyStore", "/home/..."); //path to jks certificate
System.setProperty("javax.net.ssl.keyStorePassword", "******");
System.setProperty("javax.net.ssl.requireClientAuth", "true");

u = new URL("https://...?WSDL");
is = u.openStream(); // throws an IOException
dis = new DataInputStream(new BufferedInputStream(is));

while ((s = dis.readLine()) != null) {
System.out.println(s);
}
} catch (MalformedURLException mue) {
System.out.println("Ouch - a MalformedURLException happened.");
mue.printStackTrace();
System.exit(1);
} catch (IOException ioe) {
System.out.println("Oops- an IOException happened.");
ioe.printStackTrace();
System.exit(1);
} finally {
try {
is.close();
} catch (IOException ioe) {
// just going to ignore this one
}
} // end of 'finally' clause
}

最佳答案

您的问题可能是因为 Websphere 服务器不信任远程服务器的证书。如果您的本地测试是在 Windows 上进行的,它将使用与 Internet Explorer 使用的相同的 key 存储。

与其尝试使用 System.SetProperty() 在您的 Java 代码中配置 keystore ,不如在安全性 > SSL 证书和 key 管理 > keystore 和证书下查看 Websphere 管理控制台

很可能您的 Java 代码被服务器自己的配置覆盖了。

如果您发布异常(exception)情况,您会更容易提出建议。

关于java - 从 WebSphere 连接到受 SSL 证书保护的 WebService,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7143582/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com