SSL “Peer Not Authenticated” error with HttpClient 4.1

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).

I am using HttpClient 4.1 (this is important because its API differs greatly from 3.x).

Our API is secure with SSL, however entering:

into a web browser redirects you to

Without causing any errors.

When HttpClient attempts to hit this URL (, it fails with a exception with a message stating:

peer not authenticated

I see this happening a lot for other people as is evidenced by this post (which also provides some ways of circumventing this problem – a solution that I am going to try and implement tonight in fact).

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 “why is this happening?” 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 😉


If the server’s certificate is self-signed, then this is working as designed and you will have to import the server’s certificate into your keystore.

Assuming the server certificate is signed by a well-known CA, this is happening because the set of CA certificates available to a modern browser is much larger than the limited set that is shipped with the JDK/JRE.

The EasySSL solution given in one of the posts you mention just buries the error, and you won’t know if the server has a valid certificate.

You must import the proper Root CA into your keystore to validate the certificate. There’s a reason you can’t get around this with the stock SSL code, and that’s to prevent you from writing programs that behave as if they are secure but are not.


Higher API calls when lower SDK targeted

My app supports minSdkVersion=10 and targeting 16. I want to call methods specific to API level >= 14 if a specific device supports them. I could check running OS version at runtime and whether call or not higher API methods but when I specify min SDK version, methods that exist only in versions higher than 10 are not visible.
Is there any way to use higher API methods than minSdkVersion?


Methods from higher API are invisible and inaccessible because project’s target SDK is lower than SDK which methods are going to be used. For example: if you want to use methods from API 14 Android project target SDK should be at least 14 or even better the latest (currently 16). That is kind of obvious but I missed it. After that the solution Sam gave a reference to is in use.


angularJS: how to break the link between the model and the view

I wondering if it is possible at runtime to break the link between the model and the view.
In the following example, all the are link together (through the text model). When I click the button I want to make angular to not update the last input any more (for example to start some jquery effects…).

<html ng-app>
    <script src="angular-1.0.1.js"></script>
    <input ng-model="text"/><br/>
    <input ng-model="text"/><br/>
    <input ng-model="text"/><input type="button" value="<- break!" ng-click="???"/><br/>

My real case is here:
In the jsfiddle example I expect that the old values (these that are fading) do not change any more when I press the ‘+’ button.


You can fadeOut jQuery-cloned html element:


<div ng-app="test">
    <input type="button" value=" + " ng-click="index = index + 1"/>
    <input ng-model="index" smooth="index" style="display:block"/>


angular.module('test', [])
.directive('smooth', function() {
    return {
        transclude: 'element',
        priority: 750,
        terminal: true,
        compile: function(element, attr, linker) {
            return function(scope, iterStartElement, attr) {

                var prevClone = null;

                scope.$watch(attr.smooth, function() {

                    var newScope = scope;

                    linker(newScope, function(clone) {

                        if ( prevClone ) {

                            newPrevClone = prevClone.clone();
                            newPrevClone.fadeOut(2000, function() { $(this).remove() });


                        prevClone = clone;

state_activated pre honeycomb

How do you use

<item android:drawable="@drawable/ic_launcher" android:state_activated="true"/>

for list view items in an apps that should also run on devices <11 ?

Since activated_state is not available before HC, I can only think of two dirty workarounds:

  1. Maintain the activated_state manually in your Activity.
  2. Maintain the activated element in my custom ListAdapter

But either one is satisfying. (getListView().setChoiceMode(...) wouldn’t have an effect,…)

Any other ideas?


have you had a look to this tutorial ?


Having Trouble Getting SimpleHTTPRequestHandler to respond to AJAX

I recently tried implementing the SimpleHTTPRequestHandler to accept AJAX requests according to this.

Although everything seems to work as far as receiving the request from the client, I cannot send anything back to the client, when I try to self.wfile.write(“foo”), I get a response back in the client; however, the response text from the XmlObject is completely blank!?!

If anybody can shed any light on this, that would be great!

EDIT: I think my AJAX call is structured correctly since I am getting responses from Python (I’ve checked in debug mode); however, I am not getting any message back responseText when I get an object back.


Make sure your response has a send_header() with a content type. I have seen AJAX requests get confused without this. You can also try switching your POST to a GET for debugging and make sure the browser can see the content.

Here is a simple HTTP example for returning XML if you point your query or browser to

import SimpleHTTPServer, SocketServer
import urlparse

PORT = 80

class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
   def do_GET(self):

       # Parse query data & params to find out what was passed
       parsedParams = urlparse.urlparse(self.path)
       queryParsed = urlparse.parse_qs(parsedParams.query)

       # request is either for a file to be served up or our test
       if parsedParams.path == "/test":
          # Default to serve up a local file 

   def processMyRequest(self, query):

       self.send_header('Content-Type', 'application/xml')

       self.wfile.write("<?xml version='1.0'?>");
       self.wfile.write("<sample>Some XML</sample>");

Handler = MyHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..