JNDI 两个 SSL 用于 weblogic uisng thint3client

JNDI Two SSL For weblogic uisng thint3client

我正在寻找有关如何使用 wlthint3client.jar 作为依赖项在 Weblogic 中使用 JNDI 实现双向 SSL 身份验证的示例或参考代码。

下面是使用类路径中的 wlfullclient.jar 的示例代码片段。

    //Initialize the Environment with necessary details...
    Environment env = new weblogic.jndi.Environment();
    env.setInitialContextFactory(factory);
    env.setProviderUrl(providerUrl);
    
    //Configure the trust manager with trusted certificates
//I am getting the exception mentioned in Error Snippet 1
    TrustManager tm = new weblogic.security.SSL.WLSTrustManager(sslRootCACerts);
    env.setSSLClientTrustManager(tm);
    

    //Load the client identity 
    Certificate[] sslClientCerts = .....; // Get the Client Trust Certificates
    PrivateKey clientKey = .......; ////Get the Client Key Certificate
    env.loadLocalIdentity(sslClientCerts, clientKey); //Load the user identity //Here, I am getting the exception mentioned in Error Snippet 2
    
    //Customize the SSL protocol
    SSLClientInfo sslClientInfo = (SSLClientInfo)Security.getThreadSSLClientInfo();
    SSLSocketFactory sslSocketFactory = sslClientInfo.getSSLSocketFactory();
    
    //Create the context with above information.
    env.getInitialContext();

但是,当我用 wlthint3client.jar 替换 wlfullclient.jar 时,上面的代码不起作用。下面是我遇到的异常。

错误代码段 1

java.lang.UnsupportedOperationException: This method is not supported on the standalone WebLogic client
    at weblogic.jndi.internal.SSL.ClientSSLProxyImpl.setTrustManager(ClientSSLProxyImpl.java:89)
    at weblogic.jndi.Environment.setSSLClientTrustManager(Environment.java:1163)
    at com.sample.WebLogicInitialContextFactoryThinClient.getInitialContext(WebLogicInitialContextFactoryThinClient.java:109)

错误代码段 2

Exception in thread "main" java.lang.UnsupportedOperationException: This method is not supported on the standalone WebLogic client
    at weblogic.jndi.internal.SSL.ClientSSLProxyImpl.loadLocalIdentity(ClientSSLProxyImpl.java:101)
    at weblogic.jndi.Environment.loadLocalIdentity(Environment.java:1429)

谢谢 参数

解决方案是在类路径中使用 weblogic.jar 而不是 wlthint3client.jar。