-1

I need to be able to set a system property in a Mobilefirst Java adapter (7.1). When I do add it, it seems to have no effect as it does in a stand-alone java app in eclipse. Any ideas on how to get the same function?

UPDATE: I apologize...should have added code sample....

You can see which setProperties I am referring to below....neither seem to take affect. The first one should dump out a bunch of debug info...second one will not print anything...but will fix another issue with TLSv1.2.

public String getHTTPRequest(String baseURL, String authHeader) {

    logger.info("In getHTTPRequest");
    logger.info("Parms: URL = " + baseURL + " auth = " + authHeader);
    System.setProperty("javax.net.debug", "ssl:handshake:verbose");
    System.setProperty("jsse.enableSNIExtension", "false");

    String json = "";

    try {

        SSLContext context = SSLContext.getInstance("TLSv1.2");
        context.init(null, null, null);

        SSLConnectionSocketFactory sslCF = new SSLConnectionSocketFactory(context, new HostnameVerifier() {
                @Override
                public boolean verify(String hostname, SSLSession session) {
                    // or add your own test here
                    return true;
                }
            });

        //CloseableHttpClient httpClient = HttpClientBuilder.create().setSSLSocketFactory(sslCF).build();
        HttpClientBuilder clientBuilder = HttpClientBuilder.create().setSslcontext(context);
        CloseableHttpClient httpClient = clientBuilder.build();
        HttpGet request = new HttpGet(new URI(baseURL));
        request.addHeader("Authorization", authHeader);

        CloseableHttpResponse httpResponse = httpClient.execute(request);
        json = EntityUtils.toString(httpResponse.getEntity());
        System.out.println(" Response = " + json);

    } catch (Exception e) {
        logger.info(" Exception in getHTTPRequest = " + e.toString());
    }
    return json;
}
Tim
  • 597
  • 8
  • 18
  • The question makes no sense. You also provided no code nor any example of how you're doing it, what you're using it for and why you think it's failing. Add code. – Idan Adar Jan 08 '16 at 21:17
  • Idan, I added code above and explained. I meant to say that this code is used to connect to a REST Service that only allows TLSv1.2. With this code, I got it to work in a java application in eclipse Luna. When I try and get this same code to run in a Mobilefirst 7.1.1 Java Adapter, it does not appear that the setProperty works the same way in the adapter. Maybe you have to issue setProperty type of function some other way? – Tim Jan 09 '16 at 17:11
  • I added the set property value to the jvm.options file and that seemed to work....-Djsse.enableSNIExtension=false – Tim Jan 10 '16 at 17:15
  • I'm glad you get it working. :) can you write this as an answer instead of a comment? Thanks. – Idan Adar Jan 10 '16 at 17:16

1 Answers1

0

Solution from the comments section:

I added the set property value to the jvm.options file and that seemed to work....-Djsse.enableSNIExtension=false

Idan Adar
  • 44,156
  • 13
  • 50
  • 89