【问题标题】:Connect to SSL certificate secured WebService from WebSphere从 WebSphere 连接到 SSL 证书保护的 WebService
【发布时间】:2011-08-22 05:42:47
【问题描述】:

我们有 WAS(Websphere Application Server)7 Web 服务,它是对另一方 SSL 安全 WebService 的某种代理。

当在 WAS 外部使用我们的 WebService(客户端)时(例如使用 eclipse),它会毫无问题地连接,但在 WAS 内部则不会。我还创建了测试服务,它使用功能来打印对方 WebService (Server) 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
} 

【问题讨论】:

  • 它会抛出哪个异常?
  • 是的,请发布异常跟踪。

标签: java ssl websphere


【解决方案1】:

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

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

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

如果您发布您得到的例外情况,建议会更容易。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    相关资源
    最近更新 更多