cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

Dynatrace 6.5: Fetching the XML from REST for a plugin

Hello, I am trying to create a plugin to fetch the XML data of a dashboard. (Attached .java file)testjava.txt I noticed my code worked fine with earlier versions of dynatrace with Basic HTTP Authentication for fetching REST XML. But After upgrade to 6.5 my plugin stopped working. I guess it has something to do with changed authentication in DT6.5.

Can anyone pl. help?

2 REPLIES 2

I am getting the exception:

java.security.cert.CertificateException: No subject alternative names present

Ok I was able to get this done using the snippet. Thanks to @Aftab a.

Here is the hack snippet:

  // Tell java that you don't want to go via proxy server
System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1|171.171.12.55");
// Before opening URL stream basic HTML authentication is required for dynatrace REST
Authenticator.setDefault(new Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
username, password.toCharArray());
}
});
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; }
public void checkClientTrusted(X509Certificate[] certs, String authType) { }
public void checkServerTrusted(X509Certificate[] certs, String authType) { }
}
};
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
// Create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);

🙂