Hi Malmee,

The SSL issue comes with the rest client is because you are going to invoke
HTTPS backend with out proper certificate in path.

you can set keys to the system path using following

String trustStore = System.getProperty("carbon.home") + File.separator
+ "repository" + File.separator +
                    "resources" + File.separator + "security" +
File.separator + "wso2carbon.jks";
System.setProperty("javax.net.ssl.trustStore", trustStore);
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
System.setProperty("javax.net.ssl.trustStoreType", "JKS");


In this sample WSO2 carbon keys set as keys to the system path you can
use the same.

Apache HTTP client is bit old client instead you can try some thing
like JAX-RS 2 or RestEasy client.

In All these clients you need to add above code segment to export keys
to call secured HTTP call.


Thank you,

Dharshana.


On Wed, Dec 16, 2015 at 8:56 PM, Isuru Haththotuwa <[email protected]> wrote:

> Hi Malmee,
>
> If you have used java built in methods, that would mean your tool would
> not be required to depend on an external library such as Apache HTTP client
> as you have mentioned. This is fine for a simple use case. However, please
> note if you need more functionality, such as support for all HTTP
> operations, and other capabilities, etc. it would be advisable to use
> Apache HTTP client or any other suitable existing library without
> implementing it again by yourself.
>
> For the certificate issue that you are getting, its possible to override
> the default certificate validation mechanism and plug in your own
> implementation which can disable certificate validation (for testing
> purposes). For HTTP Client 4, please see [1].
>
> [1].
> http://stackoverflow.com/questions/2703161/how-to-ignore-ssl-certificate-errors-in-apache-httpclient-4-0
>
> On Wed, Dec 16, 2015 at 8:29 PM, Malmee Weerasinghe <[email protected]>
> wrote:
>
>> Hi All,
>>
>> We have developed a HTTPS REST client using java in-built methods which
>> works properly. [1] This method is configured to allow self signed
>> certificates.
>>
>> When using apache http client we get a certificate error :
>> javax.net.ssl.SSLPeerUnverifiedException: Host name '192.168.30.227'
>> does not match the certificate subject provided by the peer (CN=localhost,
>> O=WSO2, L=Mountain View, ST=CA, C=US).
>>
>> What would be a good choice? Using apache HTTP client or java in built
>> methods. Your suggestions are highly appreciated.
>>
>> [1]
>> https://github.com/nishadi/product-private-paas/blob/master/tools/migration/ppaas-artifact-converter/src/main/java/org/wso2/ppaas/tools/artifactmigration/RestClient.java
>>
>> --
>> Malmee Weerasinghe
>> WSO2 Intern
>> mobile : (+94)* 71 7601905* |   email :   <[email protected]>
>> [email protected]
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Thanks and Regards,
>
> Isuru H.
> +94 716 358 048* <http://wso2.com/>*
>
>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 

Dharshana Warusavitharana
Senior Software Engineer , Test Automation
WSO2 Inc. http://wso2.com
email : [email protected] <[email protected]>
Tel  : +94 11 214 5345
Fax :+94 11 2145300
cell : +94770342233
blog : http://dharshanaw.blogspot.com

lean . enterprise . middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to