ssl - Https with self-signed certificate in Android over Restlet -
i'm trying implement simple androd client restlet thesis.evrything works on http have work on https self-signed certificate , have problems. unable find helpful articles or similar how implement on android restlet. know how code android developers need restlet classes.
i managed implement code execute method ( though slow, takes 20-30 seconds info server) have problems set method. used next code implement https client
private static clientresource makeinstance(string url, context con) { reference reference = new reference(url); log.d("url", url); string keystorefileabsolutepath = preferencemanager .getdefaultsharedpreferences(con).getstring( constants.pref_key_keystore_file_path, ""); system.setproperty("javax.net.ssl.truststore",keystorefileabsolutepath); system.setproperty("javax.net.ssl.truststorepassword", "ks090278d"); system.setproperty("ssl.trustmanagerfactory.algorithm", javax.net.ssl.keymanagerfactory.getdefaultalgorithm()); org.restlet.context context = new org.restlet.context(); context.getattributes().put("hostnameverifier", new hostnameverifier() { @override public boolean verify(string arg0, sslsession arg1) { homecoming true; } }); clientresource resource = new clientresource(context, reference); engine.getinstance().getregisteredclients().clear(); engine.getinstance().getregisteredclients() .add(new httpclienthelper(null)); resource.release(); homecoming resource; }
and i'm using this
clientresource request = new clientresource(url); request.setretryattempts(0); series<header> responseheaders = (series<header>) request.getresponse() .getattributes().get("org.restlet.http.headers"); if (responseheaders == null) { responseheaders = new series(header.class); request.getrequestattributes().put("org.restlet.http.headers", responseheaders); } responseheaders.add(new header("accept", "application/json;")); responseheaders.add(new header("content-type", "application/json;")); responseheaders.add(new header("authorization", "basic zxn0dwrlbnq6yw5kcm9pza==;")); seek { request.put(new jsonrepresentation(jsonstring)); response response = request.getresponse(); if (response != null) { log.d("response", "http response: " + response.tostring()); responsehandler .handleresponse(response); } } grab (exception e) { }
when execute request i'm getting "internal server error - 500". i'm using same code method insted of
request.put(new jsonrepresentation(jsonstring));
i'm doing
request.get();
and works (though slow mentioned above).
i checked if due error server think not because managed appropriate response when i'm using code similar code android developers , when i'm trying execute set same url restclient in chrome.
can give me suggestions how work? i'm not sure if aproach begin with, may i'm gooing in wrong direction start. thnaks in advance.
android ssl restlet self-signed
No comments:
Post a Comment