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 8796873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:43:18+00:00 2026-06-13T23:43:18+00:00

I tried to contact an https server with the following code: HttpResponse response =

  • 0

I tried to contact an https server with the following code:

HttpResponse response = new DefaultHttpClient().execute(new HttpGet("https://www.google.com"));

and it works perfectly (it returns the google page and the status code 200 OK).

I also tried to contact the same server with the following one:

BasicHttpParams clientparams = new BasicHttpParams();
[... clientparams initializazion...]

SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));

SSLSocketFactory sf = SSLSocketFactory.getSocketFactory();
sf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
schemeRegistry.register(new Scheme("https", sf, 443));

ClientConnectionManager cm = new ThreadSafeClientConnManager(clientparams, schemeRegistry);
HttpClient myClient = new DefaultHttpClient(cm, clientparams);
HttpResponse response = myClient.execute(new HttpGet("https://www.google.com"));

and this works perfectly too. I tried also with other servers and always it works.

Then, can someone explain to me when I need to use a SchemeRegistry to initialize an http client? And also, in which cases it is necessary to inizialize a SSLSocketFactory with a custom KeyStore?

  • 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-06-13T23:43:20+00:00Added an answer on June 13, 2026 at 11:43 pm

    I believe it comes down to the certificate that the server is using on its SSL connection. If it is something Android recognizes due to being root CA (usually these will be certificates from the more common sources, like Verisign for example) then it should work like you have here.

    On other hand, if there is a custom certificate, or something self-signed, or something from a source that is maybe smaller or not generally accepted as being secure, then you will have to create a custom keystore to manually deal with that certificate.

    Google likely uses the former, which is why your code works already.

    Also, I believe you can add

    schemeRegistry.register(new Scheme("http", sf, 80));
    

    to your code and it will cover http connections as well without causing any harm to your application.

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

Sidebar

Related Questions

Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
Tried following the instructions here: How to use Google app engine with my own
I'm trying to contact a server using $.get(). I don't care about the response.
I have strange problem. For a project we are using following cloud hosting. http://www.rackspace.com
I have the following URL: https://api-test.company.com/contacts?q=email= jlowder@company.com I am parsing it using: String URL
I tried to make a simple contact form via HTML and PHP but the
I got the following code and before sending i check the fields are populated
I'm trying to user MiddlemanApp to localize a website, following this http://middlemanapp.com/guides/localization guide. I
I've tried copying a a CiviCRM/Drupal install from 1 server to another. I copied
I have purchased the following script from codecanyon http://codecanyon.net/item/contact-me-contact-form-admin-panel-v2/148836 and then I have added

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.