title: SSL "Peer Not Authenticated" error with HttpClient 4.1
body: <p>I am building a simple app monitor to poll one of our API URLs and email us if it can't get a HTTP 200 status code from the response (this would indicate our API is down for some reason).</p>
  
  <p>I am using HttpClient <strong>4.1</strong> (this is important because its API differs <em>greatly</em> from 3.x).</p>
  
  <p>Our API is secure with SSL, however entering:</p>
  
  <blockquote>
    <p><a href="http://example.com/our-api" rel="noreferrer">http://example.com/our-api</a></p>
  </blockquote>
  
  <p>into a web browser redirects you to</p>
  
  <blockquote>
    <p><a href="https://example.com/our-api" rel="noreferrer">https://example.com/our-api</a></p>
  </blockquote>
  
  <p>Without causing any errors.</p>
  
  <p>When HttpClient attempts to hit this URL (<code>http://example.com/our-api</code>), it fails with a <code>javax.net.ssl.SSLPeerUnverifiedException</code> exception with a message stating:</p>
  
  <blockquote>
    <p>peer not authenticated</p>
  </blockquote>
  
  <p>I see this happening a lot for other people as is evidenced by <a href="https://stackoverflow.com/questions/2308774/httpget-with-https-sslpeerunverifiedexception">this</a> post (which also provides some ways of circumventing this problem - a solution that I am going to try and implement tonight in fact).</p>
  
  <p>What this other post (and the other similar ones to it) do not do is explain why this is happening in the first place! So, rather than ask "how do I fix this?" I figured I would ask "<strong>why is this happening?</strong>" Before I go barging ahead with one of the proposed solutions, I'd like to know what the problem is that I'm attempting to fix ;-)</p>