0

Hello every professional,

I'm a new in Android development, recently, I just get into Android area, now I encountered a problem when I tried to access server application with HTTPS request (Like https://DEVELOPMENT_SAMPLE.com/project), we use Spring for Android to handle request, and use ApacheHTTP Server + Tomcat + SSL` as a deployment environment. When I use HTTP request instead of HTTPS request and remove SSL from the deployement environment, the access can be successfully handled. I share the related code from here:

    RestTemplate restTemplate = new RestTemplate();
    restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
    restTemplate.getMessageConverters().add(new StringHttpMessageConverter());

    HttpComponentsClientHttpRequestFactory factory = new
HttpComponentsClientHttpRequestFactory();
    factory.setConnectTimeout(1000 * 15);
    restTemplate.setRequestFactory(factory);

I know There are two native HTTP clients available on Android, the standard J2SE facilities, and the HttpComponents HttpClient. The standard JS2SE facilities are made available through the SimpleClientHttpRequestFactory, while the HttpClient is made available through the HttpComponentsClientHttpRequestFactory. The default ClientHttpRequestFactory used when you create a new RestTemplate instance differs based on the version of Android on which your application is running.

But the question I want to ask is how to make my HTTPS is available for Android client? I guess some change should be made in getting Connection object.

Thanks so much.

Brady Zhu
  • 1,305
  • 5
  • 21
  • 43

1 Answers1

1

Yes, Android can communicate with HTTPS. Read this link:

Accepting a certificate for HTTPS on Android

See also this excellent article:

Making Android SSL Work Correctly

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190