Question

I plan to connect via HTTPS to a server using the Innovation HTTP Client.

I need to be able to accept all server SSL certificates.

There are some examples using HttpsURLConnection, but I need to use the Innovation implementation.

Does anyone have any examples for Innovation HTTP Client?

Était-ce utile?

La solution

Innovation HTTPClient doesn't directly support HTTPS. See this page on the Innovation website for more information. There are a number of 3rd party patches and examples listed there which you can implement. Setting certificate acceptance depends on the patch implementation you choose.

EDIT / UPDATE

Note that JSSE SSL implementation is being used and the intent is to define a TrustedManager and bind it via SSLContext to HTTPConnection.

Assuming you know how to create a TrustManager, the following code is co-opted from this Stackoverflow page, which also shows how to generate one.

TrustManager[] trustAllCerts = new TrustManager[] { ... };

// Install the all-trusting trust manager
try {
    SSLContext sc = SSLContext.getInstance("TLS");
    sc.init(null, trustAllCerts, new java.security.SecureRandom());

Per the README file I got from the JSSE SSL download off the Innovation website link from earlier, you can assign it to the HTTPConnection by doing this:

    // Attach context to connection via socket factory
    HTTPConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());

} catch (Exception e) { ... }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top