本文介绍了具有自定义SSLSocketFactory的T3客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的T3客户端代码:

I have my T3 client code like this:

private InitialContext initContext() {
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, context.providerURL);

    for (Map.Entry<String, String> entry : getEnvironmentProperties().entrySet()) {
        p.put(entry.getKey(), entry.getValue());
    }

    InitialContext res = null;
    try {
        res = new InitialContext(p);
    } catch (NamingException e) {
        e.printStackTrace();
    }

    return res;
}

我的t3客户端部署在Tomcat上(使用wlthint3client-12.1.3.jar)并尝试查找部署在Weblogic上的外部系统的远程bean。

My t3 client deployed on Tomcat (uses wlthint3client-12.1.3.jar) and trying to lookup remote bean of external system which deployed on Weblogic.

但是,当我尝试执行新的InitialContext(p)时,会收到SSLHandshake异常,因为它会获得带有standart SSLConext和standart java信任库的standart SSLSocketFactory。

However when I trying to perform new InitialContext(p) I receive SSLHandshake exception, because it gets standart SSLSocketFactory with standart SSLConext and standart java trust store.

我的问题-有什么办法可以赋予InitialContext一些将覆盖SSLSocketFacory的属性。我的目标是向该t3客户端填充我的cutum信任库。

My question - is there any way to give to InitialContext some property which will override SSLSocketFacory. My aim is to populate my cutom trust store to this t3 client.

像这样的不断变化的标准信托商店

Changing standart trust store like this

System.setProperty("javax.net.ssl.trustStore", "pathToTrustStore"); 

工作正常,但是如果我的t3客户端用于与2个不同的外部系统进行通信,这样做可能是个问题。

works fine, however in case if my t3 client is used to communicate with 2 different external systems, it might be a problem in doing so.

是否可以提供一些物业?

Is there some property that I can populate?

Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
**p.put("CUSTOM SSL SOCKET FACTORY, "MY CLASS");**


推荐答案

通过在应用程序端添加一些参数来解决问题

Problem was solved by adding few parameters on application side

export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStore=path/truststore.jks"
export JAVA_OPTS ="$JAVA_OPTS -Djavax.net.ssl.trustStorePassword=changeIT"

这篇关于具有自定义SSLSocketFactory的T3客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 11:25