Hi,
We are currently hitting a show-stopper issue which is preventing us from being able to deliver and certify our plugin. Would you please be able to help?
Our code originated from the plugin-seed 0.9.7. It uses a custom data adapter to connect to our appliance's REST API and retrieve data. This works well when we are connecting to an HTTP endpoint (using RestTemplate), and the data is all returned as expected.
However, when attempting to connect to an HTTPS endpoint, the connection fails as it is not authorised (due to SSL). This is expected behaviour, and we have tried to circumvent this using the code provided here: http://www.baeldung.com/httpclient-ssl
This code works as expected, and returns our data when built within a simple Java application with required dependencies (including introduced Apache HTTP libraries).
However, when we try running the code within the plugin we get a failure on installation to the Virgo server, as follows:
We believe all the required dependencies are there, equivalent to the dependencies in our simple application. These are included in the Manifest and included within the JAR on build (Bundle-Classpath). I have included the MANIFEST.MF with the post.
The project builds the .JAR fine using ANT. When our class is being statically initialised, the error occurs at the point shown below:
private static SSLContext sslContext; private static CloseableHttpClient httpClient; private static ClientHttpRequestFactory httpRequestFactory; private static RestTemplate restTemplate = new RestTemplate(); static { try { sslContext = new SSLContextBuilder() .loadTrustMaterial(null, new TrustStrategy() { @Override public boolean isTrusted(X509Certificate[] certificate, String authType) throws CertificateException { return true; } }).build(); } catch (KeyManagementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchAlgorithmException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (KeyStoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } httpClient = HttpClients.custom() .setSSLContext(sslContext) .setSSLHostnameVerifier(new NoopHostnameVerifier()) .build(); httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); restTemplate.setRequestFactory(httpRequestFactory); //<---- This is causing error }
This is preventing us from continuing any work on the plugin. We have no idea how to proceed towards a solution. Could you please let us know what we can do, or what we can provide, to diagnose and solve this problem ASAP?
Many thanks,
Warren