Hi Kishanthan,

Thanks for the information. I'll follow up these.


On Fri, Nov 29, 2013 at 5:46 PM, Kishanthan Thangarajah <
[email protected]> wrote:

> This may help :
> http://javaskeleton.blogspot.com/2010/07/avoiding-peer-not-authenticated-with.html,
> but it is for dev/testing purpose only. This usually comes when trying to
> connect to a server which doesn't have a trusted certificate.
>
> If we want to dig deep then we can follow :
> http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/ReadDebug.html
>
>
> On Fri, Nov 29, 2013 at 5:08 PM, Manula Chathurika Thantriwatte <
> [email protected]> wrote:
>
>> Hi All,
>>
>> I'm working on $subject. I have implemented mock Java client which
>> communicate with Stratos Manager. When I'm going to execute add tenant CLI
>> command using post request, I'm getting following error.
>>
>> javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
>>     at
>> com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
>>     at
>> org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:128)
>>     at
>> org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:390)
>>     at
>> org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148)
>>     at
>> org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
>>     at
>> org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:121)
>>     at
>> org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:561)
>>     at
>> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
>>     at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
>>     at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754)
>>     at
>> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732)
>>     at TestCLI.doPost(TestCLI.java:56)
>>     at TestCLI.main(TestCLI.java:40)
>>
>> Any idea about this error ?
>>
>> Here I attach doPost method implementations which I'm using.
>>
>>     public String doPost(String resourcePath, String jsonParamString) {
>>         try {
>>
>>             DefaultHttpClient httpClient = new DefaultHttpClient();
>>
>>             HttpPost postRequest = new HttpPost(resourcePath);
>>
>>             StringEntity input = new StringEntity(jsonParamString);
>>             input.setContentType("application/json");
>>             postRequest.setEntity(input);
>>
>>             httpClient.getCredentialsProvider().setCredentials(new
>> AuthScope(host, AuthScope.ANY_PORT), new
>> UsernamePasswordCredentials("admin", "admin"));
>>
>>             HttpResponse response = httpClient.execute(postRequest);
>>
>>             System.out.println(response.getStatusLine());
>>
>>             if (response.getStatusLine().getStatusCode() != 201) {
>>                 System.out.println("Error");
>>                 throw new RuntimeException("Failed : HTTP error code : "
>> + response.getStatusLine().getStatusCode());
>>             }
>>
>>             BufferedReader br = new BufferedReader(new
>> InputStreamReader((response.getEntity().getContent())));
>>
>>             String output;
>>             System.out.println("Output from Server .... \n");
>>             while ((output = br.readLine()) != null) {
>>                 System.out.println(output);
>>             }
>>
>>             httpClient.getConnectionManager().shutdown();
>>             return output;
>>
>>         } catch (MalformedURLException e) {
>>             e.printStackTrace();
>>             return null;
>>         } catch (IOException e) {
>>             e.printStackTrace();
>>             return null;
>>         }
>>     }
>>
>> Thanks !
>>
>> --
>>  Regards,
>> Manula Chathurika Thantriwatte
>> Software Engineer
>> WSO2 Inc. : http://wso2.com
>> lean . enterprise . middleware
>>
>> email : [email protected] / [email protected]
>> phone : +94 772492511
>> blog : http://manulachathurika.blogspot.com/
>>
>>
>>
>>
>


-- 
Regards,
Manula Chathurika Thantriwatte
Software Engineer
WSO2 Inc. : http://wso2.com
lean . enterprise . middleware

email : [email protected] / [email protected]
phone : +94 772492511
blog : http://manulachathurika.blogspot.com/

Reply via email to