You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Adrián Roselló Rey <ad...@i2cat.net> on 2014/07/18 14:49:42 UTC
JAXRS - disable CN Check Programatically
Hi all!
I'm having some problems with SSL and JAX-RS clients. I create JAX-RS
clients programatically with the JAXRSClientFactoryBean like this;
* ProxyClassLoader classLoader = new ProxyClassLoader();
classLoader.addLoader(apiClass.getClassLoader());
classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address); bean.setResourceClass(MyClass.class);
bean.setClassLoader(classLoader); return
bean.create(MyClass.class);*
When I test my client doing a request to the real server, I receive
following exception
j
*Caused by: java.io.IOException: IOException invoking
https://83.212.32.165:8001/resources/lease
<https://83.212.32.165:8001/resources/lease>: The https URL hostname does
not match the Common Name (CN) on the server certificate in the client's
truststore. Make sure server certificate is correct, or to disable this
check (NOT recommended for production) set the CXF client TLS configuration
property "disableCNCheck" to true. at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
....*
For a first approach, I just want to disable CN check as mentioned, but I I
haven't seen how do it programatically. Is there any way to do that?
Thanks!
All the best,
Adrián Roselló Rey
--
* Adrián Roselló Rey Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain*
T: +34 93 553 25 49
http://dana.i2cat.net
Re: JAXRS - disable CN Check Programatically
Posted by Adrián Roselló Rey <ad...@i2cat.net>.
Thanks Sergey! It worked for me.
All the best,
Adrián Rosello Rey
2014-07-18 17:40 GMT+02:00 Sergey Beryozkin <sb...@gmail.com>:
> Hi
>
> WebClient.getConfig(myproxy).getHttpConduit() will return HTTPConduit
>
> and then you can configure HttpConduit directly.
>
> Please also try experimenting with JAX-RS 2.0 Client API (CXF 3.0.0+ only)
>
> Thanks, Sergey
>
>
> On 18/07/14 13:49, Adrián Roselló Rey wrote:
>
>> Hi all!
>>
>> I'm having some problems with SSL and JAX-RS clients. I create JAX-RS
>> clients programatically with the JAXRSClientFactoryBean like this;
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> * ProxyClassLoader classLoader = new ProxyClassLoader();
>>
>> classLoader.addLoader(apiClass.getClassLoader());
>> classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
>> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
>> bean.setAddress(address); bean.setResourceClass(MyClass.class);
>> bean.setClassLoader(classLoader); return
>> bean.create(MyClass.class);*
>>
>>
>> When I test my client doing a request to the real server, I receive
>> following exception
>>
>>
>> j
>>
>>
>>
>> *Caused by: java.io.IOException: IOException invoking
>>
>> https://83.212.32.165:8001/resources/lease
>> <https://83.212.32.165:8001/resources/lease>: The https URL hostname does
>> not match the Common Name (CN) on the server certificate in the client's
>> truststore. Make sure server certificate is correct, or to disable this
>> check (NOT recommended for production) set the CXF client TLS
>> configuration
>> property "disableCNCheck" to true. at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> ....*
>>
>>
>>
>> For a first approach, I just want to disable CN check as mentioned, but I
>> I
>> haven't seen how do it programatically. Is there any way to do that?
>>
>> Thanks!
>>
>> All the best,
>>
>> Adrián Roselló Rey
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>
--
* Adrián Roselló Rey Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain*
T: +34 93 553 25 49
http://dana.i2cat.net
Re: JAXRS - disable CN Check Programatically
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
WebClient.getConfig(myproxy).getHttpConduit() will return HTTPConduit
and then you can configure HttpConduit directly.
Please also try experimenting with JAX-RS 2.0 Client API (CXF 3.0.0+ only)
Thanks, Sergey
On 18/07/14 13:49, Adrián Roselló Rey wrote:
> Hi all!
>
> I'm having some problems with SSL and JAX-RS clients. I create JAX-RS
> clients programatically with the JAXRSClientFactoryBean like this;
>
>
>
>
>
>
>
>
>
>
>
>
>
> * ProxyClassLoader classLoader = new ProxyClassLoader();
> classLoader.addLoader(apiClass.getClassLoader());
> classLoader.addLoader(JAXRSClientFactoryBean.class.getClassLoader());
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(address); bean.setResourceClass(MyClass.class);
> bean.setClassLoader(classLoader); return
> bean.create(MyClass.class);*
>
> When I test my client doing a request to the real server, I receive
> following exception
>
>
> j
>
>
>
> *Caused by: java.io.IOException: IOException invoking
> https://83.212.32.165:8001/resources/lease
> <https://83.212.32.165:8001/resources/lease>: The https URL hostname does
> not match the Common Name (CN) on the server certificate in the client's
> truststore. Make sure server certificate is correct, or to disable this
> check (NOT recommended for production) set the CXF client TLS configuration
> property "disableCNCheck" to true. at
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> ....*
>
>
> For a first approach, I just want to disable CN check as mentioned, but I I
> haven't seen how do it programatically. Is there any way to do that?
>
> Thanks!
>
> All the best,
>
> Adrián Roselló Rey
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com