CXF RESTful client - how to trust all certificates?


sdoca:

I wrote a Jersey RESTful client that uses the Dumb X509TrustManager and HostnameVerifier to trust all SSL certificates on our lab system to make it easier to handle self-signed certificates.

        ClientConfig config = new DefaultClientConfig();
        SSLContext context = null;
        try
        {
            context = SSLContext.getInstance("SSL");
            context.init(null,
                    new TrustManager[] { new DumbX509TrustManager() },
                    null);
            config.getProperties()
                    .put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
                            new HTTPSProperties(this.getHostnameVerifier(),
                                    context));
            webClient = Client.create(config);
        }
        ....

Is there a way for me to do something similar using CXF?

sdoca:

This is from the CXF mailing list. Note that I didn't have to implement it due to other system updates, so this is theoretical:

WebClient webClient = WebClient.create(this.serviceURL,
    this.username,
    this.password,
    null); // Spring config file - we don't use this

if (trustAllCerts)
{
    HTTPConduit conduit = WebClient.getConfig(webClient)
        .getHttpConduit();

    TLSClientParameters params = 
        conduit.getTlsClientParameters();

    if (params == null) 
    {
        params = new TLSClientParameters();
        conduit.setTlsClientParameters(params);
    }

    params.setTrustManagers(new TrustManager[] { new
        DumbX509TrustManager() }); 

    params.setDisableCNCheck(true);
}

Related


CXF RESTful client - how to trust all certificates?

sdoca: I wrote a Jersey RESTful client that uses the Dumb X509TrustManager and HostnameVerifier to trust all SSL certificates on our lab system to make it easier to handle self-signed certificates. ClientConfig config = new DefaultClientConfig();

Trust all certificates with okHttp

seato: seato: For testing, I'm trying to add a socket factory to my okHttp client that trusts everything when setting up the proxy. This has been done many times, but my implementation of the trusted socket factory seems to be missing something: class TrustEve

Trust all certificates with okHttp

seato: seato: For testing, I'm trying to add a socket factory to my okHttp client that trusts everything when setting up the proxy. This has been done many times, but my implementation of the trusted socket factory seems to be missing something: class TrustEve

Trust all certificates with okHttp

seato: seato: For testing, I'm trying to add a socket factory to my okHttp client that trusts everything when setting up the proxy. This has been done many times, but my implementation of the trusted socket factory seems to be missing something: class TrustEve

Trust all certificates with HttpClient over HTTPS

Harrison Leigh: Recently posted a question about over HttpClientHttps ( found here ). I've made some progress, but I'm running into a new problem. As with my last question, I can't seem to find an example that works for me. Basically, I want my client to accep

Trust all SSL certificates in Java Playframework 2.2

asvignesh: I'm trying to call a web service (with a self-signed SSL certificate) in the Play framework using the following function: public static play.libs.F.Promise<Result> webcall() { String feedUrl = "https://10.0.1.1/client/api"; final play.

Trust all certificates with HttpClient over HTTPS

Harrison Leigh: Recently posted a question about over HttpClientHttps ( found here ). I've made some progress, but I'm running into a new problem. As with my last question, I can't seem to find an example that works for me. Basically, I want my client to accep

Trust all SSL certificates in Java Playframework 2.2

asvignesh: I'm trying to call a web service (with a self-signed SSL certificate) in the Play framework using the following function: public static play.libs.F.Promise<Result> webcall() { String feedUrl = "https://10.0.1.1/client/api"; final play.

Trust all SSL certificates in Java Playframework 2.2

Avines I'm trying to call a web service (with a self-signed SSL certificate) in the Play framework using the following function: public static play.libs.F.Promise<Result> webcall() { String feedUrl = "https://10.0.1.1/client/api"; final play.libs

Trust all certificates with HttpClient over HTTPS

Harrison Leigh: Recently posted a question about over HttpClientHttps ( found here ). I've made some progress, but I'm running into a new problem. As with my last question, I can't seem to find an example that works for me. Basically, I want my client to accep

Trust all SSL certificates in Java Playframework 2.2

asvignesh: I'm trying to call a web service (with a self-signed SSL certificate) in the Play framework using the following function: public static play.libs.F.Promise<Result> webcall() { String feedUrl = "https://10.0.1.1/client/api"; final play.

CXF: How to dynamically provide SSL certificates?

Artem I have generated CXF 2.7.10 client for SOAP SSL WebService. How can I give it a private key/certificate (ideally in pem format) at runtime instead of hardcoding the JKS in the XML config? David Lizesky Take a look at this blog post where an implementatio

CXF: How to dynamically provide SSL certificates?

Artem I have generated CXF 2.7.10 client for SOAP SSL WebService. How can I give it a private key/certificate (ideally in pem format) at runtime instead of hardcoding the JKS in the XML config? David Lizesky Take a look at this blog post where an implementatio