0

In my android code, I am trying to connect to one particular url like

URL url = new URL(urlStr);

HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();

Here my app is trying to connect to the url(https) via SSL in some set of mobile phones and uses TLS as underlying protocol. Since the target server only accepts TLS it's failing for the mobile phones which initiates https connections via SSL.

Have confirmed the above behavior's via wireshark.

Is there a way like my app can initiate https connections only via TLS.

Thanks.

1
  • "Since the target server only accepts TLS it's failing for the mobile phones which initiates https connections via SSL." It shouldn't do that. It should upgrade the connection during the handshake. Please post the actual error message you get. Commented Apr 15, 2015 at 8:31

1 Answer 1

0

You can do that by setting the provider with the SSLContext class.

SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); SSLSocketFactory factory = context.getSocketFactory(); httpURLConnection.setSSLSocketFactory(factory); 

But there is a known issue so it might not work on all devices. For more info on SSL see the android training.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response. I am using the code whatever you have commented out there. Let me look into the links that you have suggested.
Is there any other ways like I can tell my app connect to https based urls only via tls....

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.