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

  • Home
  • SEARCH
  • 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 6750979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:52:20+00:00 2026-05-26T12:52:20+00:00

When using the Apache HttpComponents HttpClient library (4.0.2) I’m having a problem where the

  • 0

When using the Apache HttpComponents HttpClient library (4.0.2) I’m having a problem where the certificate doesn’t get validated properly. The certificate is valid for the domain name (let’s call it example.com) however it’s getting validated against the IP address instead:

hostname in certificate didn’t match: <123.123.123.123> !=
<*.example.com>

My code for making the connection is:

    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
    HttpConnectionParams.setSoTimeout(httpParams, 5000);
    DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);            
    String url = "https://www.example.com";
    HttpGet get = new HttpGet(url);
    HttpResponse httpResponse = httpClient.execute(get);
    String response = EntityUtils.toString(httpResponse.getEntity()).trim();

The certificate itself shows as valid when connecting through a web browser and is valid for the domain name I’m connecting to:

CN = *.example.com

The certificate is also added to the Java keystore (tested using regular HttpsURLConnection).

Any ideas why this code uses the IP address instead of the domain name?

  • 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-26T12:52:20+00:00Added an answer on May 26, 2026 at 12:52 pm

    Appears to be a known bug with HttpClient 4.0.2 – https://issues.apache.org/jira/browse/HTTPCLIENT-996
    The bug suggests any of the following:

    • Upgrade to version 4.0.3 or newer
    • Downgrade to 4.0.1
    • Use the AllowAllHostnameVerifier
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Apache POI to generate a document and i'm having a small problem with
I'm using Apache Common library for HTTP operations: HttpClient client = getClient(); PutMethod put
I'm fetching a web page using the Apache httpcomponents Java library . After connecting
I'm using Apache HttpComponents (core - 4.1.3, httpclient 4.1.1) to make http requests in
Using Apache's commons-httpclient for Java, what's the best way to add query parameters to
I am using Apache HttpClient and would like to communicate HTTP errors (400 Bad
I am using Apache Commons Email library to send emails, but I am not
I'm using Apache Commons Configuration library to store my app properties. I can monitor
I'm using Apache common fileupload library with Netbeans 6.8 + Glassfish.I'm trying to change
I'm using a connection created by ThreadSafeClientConnManager (Apache httpcomponents 4.1.1). The response is chunked

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.