0

I am using vmware API. By using this API I am able to get information of ESX devices. Now I want to get information about vcenter using this API, but get exception:

java.rmi.RemoteException: VI SDK invoke exception:javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints

Here is a code:

                    public void realesx(){
    System.out.println("Running ESX Realtime for host ..."+host);
    JSONObject esxcmdout = new JSONObject();
    String url = "https://" + host + "/sdk/vimService";
    try {
    ServiceInstance si = new ServiceInstance(new URL(url), user, pass,true);
    System.out.println("host :"+host+"---"+si.getAboutInfo().getFullName());

    System.out.println(" Version is .. " +si.getAboutInfo().version);
    System.out.println(" os type is .. " +si.getAboutInfo().osType);
    System.out.println("Vendor is .. " + si.getAboutInfo().vendor);
    System.out.println("name is" + si.getAboutInfo().name);

ManagedEntity[] managedEntities = new InventoryNavigator(
            si.getRootFolder()).searchManagedEntities("VirtualMachine");
ManagedEntity[] hostmanagedEntities = new InventoryNavigator(
            si.getRootFolder()).searchManagedEntities("HostSystem");

for (ManagedEntity hostmanagedEntity : hostmanagedEntities) {
HostSystem hostsys = (HostSystem) hostmanagedEntity;

String ESXhostname = hostsys.getName();
//System.out.println("main system version is .. " + hostsys.getConfig());

HostListSummary hls = hostsys.getSummary();
        HostHardwareSummary hosthwi = hls.getHardware();
        HostListSummaryQuickStats hqs = hls.getQuickStats();
        Datastore[] HDS = hostsys.getDatastores();
        StringBuilder DS = new StringBuilder();
        for (int i=0;i <HDS.length;i++){
            DatastoreSummary dsm =HDS[i].getSummary();

            DS.append(dsm.name+":"+dsm.capacity+":"+dsm.freeSpace+"-");
        }

int MEM=hqs.overallMemoryUsage;
int UPT=hqs.getUptime();
Integer CPU=hqs.getOverallCpuUsage();   

String esxkey = "ESXRealInfo";
String esxvalue = "ESXhostname-" + ESXhostname
        + ";CPU Usage-" + CPU + ";MEM Usage-"
        + MEM + ";UPTIME-" + UPT+"; Datastores -"+DS;
try {
    esxcmdout.put(esxkey, esxvalue);
} catch (JSONException e) {
    // TODO Auto-generated catch block
e.printStackTrace();
}
}

si.getServerConnection().logout();
}

catch (InvalidProperty e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (RuntimeFault e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (RemoteException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}


}

This code works fine for collecting information of ESX devices. How do I resolve error of certificate for vcenter? Is there any alternative way to do this?

Vishwas
  • 6,967
  • 5
  • 42
  • 69

1 Answers1

1

One of the reasons for getting this exception is when the certificate provided by HTTPs server (vCenter Server in your case) is signed using MD2 algorithm and the HTTP Client (your code) is using JAVA 7. See this post for more details. Try one of the 2 options below.

  1. Use JAVA 6.
  2. Comment out line "jdk.certpath.disabledAlgorithms=MD2" in file JDK_HOME/jre/lib/security/java.security

Check if the error is resolved.

Community
  • 1
  • 1
Tushar Tarkas
  • 1,592
  • 13
  • 25