Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898792
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:48:50+00:00 2026-05-17T06:48:50+00:00

I am trying to create a https connection and its working fine in a

  • 0

I am trying to create a https connection and its working fine in a test class.but when i call the same method in action class its getting following error after step 666666666666.

java.net.SocketException
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:8)
at com.ibm.net.ssl.www2.protocol.https.b.afterConnect(b.java:29)
at com.ibm.net.ssl.www2.protocol.https.c.connect(c.java:34)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:943)
at com.ibm.net.ssl.www2.protocol.https.a.getInputStream(a.java:13)

the method is following.

public static String logOn(String reqXML){

    String responseXml="";
    try {
        JConfigUtil configuratorTest = JConfigUtil.getInstance();
        String LogOn_URL = configuratorTest.getProperty(CenturionConst.Centurion,CenturionConst.LogOnService_URL);
    //  System.out.println("Log On URL :"+LogOn_URL);
        String param = URLEncoder.encode(reqXML,"UTF8");
        String inputUrl=LogOn_URL+param;
        System.out.println("11111111111111111");
        System.setProperty("javax.net.ssl.trustStore", CERT_FILE_LOC);

        System.out.println("22222222222222222");

        HostnameVerifier hv = new HostnameVerifier() {
            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
                return true;
            }
        };
        System.out.println("33333333333333333");
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        System.out.println("444444444444444444");
        System.out.println(inputUrl);
        URL url = new URL(inputUrl);
        HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
        System.out.println("555555555555555555");
        connection.setDoOutput(true);
        System.out.println("6666666666666666666");
        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String line;
        System.out.println("77777777777777777777");
        while ((line = in.readLine()) != null) {
            responseXml=responseXml+line;
            }
        in.close();
        System.out.println("8888888888888888888888");
    }  catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return responseXml;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:48:50+00:00Added an answer on May 17, 2026 at 6:48 am

    call trustAllHttpsCertificates() before
    HostnameVerifier hv = new HostnameVerifier() and it ll work

    package com.americanexpress.mobl.centurion.app.util;

    import java.security.cert.CertificateException;
    import java.security.cert.X509Certificate;

    public class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager{

    public void checkClientTrusted(X509Certificate[] certs, String authType)
            throws CertificateException {
        // TODO Auto-generated method stub
        return;
    }
    
    public void checkServerTrusted(X509Certificate[] certs, String authType)
            throws CertificateException {
        // TODO Auto-generated method stub
        return;
    }
    
    public X509Certificate[] getAcceptedIssuers() {
        // TODO Auto-generated method stub
        return null;
    } 
    public boolean isClientTrusted(java.security.cert.X509Certificate[] certs)
    {
        return true;
        }
    public boolean isServerTrusted(java.security.cert.X509Certificate[] certs)
    {
        return true;
        }
    

    public static void trustAllHttpsCertificates() throws Exception{
    javax.net.ssl.TrustManager[] trustAllCerts = new javax.net.ssl.TrustManager[1];
    javax.net.ssl.TrustManager tm = new miTM();
    trustAllCerts[0] = tm;
    javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance(“SSL”);
    sc.init(null, trustAllCerts, null);
    javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    }

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a 2-way videochat. Your own webcam shows perfectly fine, but
I am trying to create a chat application on heroku using the following https://github.com/tarnfeld/PusherChat-Rails
i'm trying to create following layout: http://jsfiddle.net/BTuMH/1/ but without setting the width, like: http://jsfiddle.net/yuGyg/
I'm trying to create a test fixture using Fitnesse framework, and I want to
Here's the response I keep getting when trying to create a new activity: {error:{errors:[{message:Unknown
I am trying to use openSSL to set up an https connection for my
I'm trying to create a login system for my jQuery mobile app but it's
I'm trying to create this effect: http://www.thecssninja.com/demo/css_tree/ the problem I'm having is that the
I am trying to create some charts of data (eg http://www.amibroker.com/ ). Is there
I'm trying to create a layout similar to this: alt text http://img20.imageshack.us/img20/3533/stackn.png Here's the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.