T3 client with custom SSLSocketFactory

一笑奈何 提交于 2019-12-31 05:37:07

问题


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;
}

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.

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.

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"); 

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");**

回答1:


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"


来源:https://stackoverflow.com/questions/52369236/t3-client-with-custom-sslsocketfactory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!