i have one java program that connects to one server and interacts with that server and does (say hello world) simple task.
my java program is to interact with vmware esxi server. with the following code.
ServiceInstance si = new ServiceInstance(new URL("https://10.100.13.36/sdk"), "root", "teamw0rk", true)
true parameter indicates that the ignore certificate to true.
even it is a vmware interaction the library it is purely a problem with certificate.Because when i put false for ignore certificate. i got the general certificate expectation from the library files.
the program is as follows.
package com.vmware.vim25.mo.samples;
import java.net.URL;
import com.vmware.vim25.*;
import com.vmware.vim25.mo.*;
public class HelloVM
{
public static void main(String[] args) throws Exception
{
long start = System.currentTimeMillis();
ServiceInstance si = new ServiceInstance(new URL("https://10.100.13.36/sdk"), "root", "teamw0rk", false);
long end = System.currentTimeMillis();
System.out.println("time taken:" + (end-start));
Folder rootFolder = si.getRootFolder();
String name = rootFolder.getName();
System.out.println("root:" + name);
ManagedEntity[] mes = new InventoryNavigator(rootFolder).searchManagedEntities("VirtualMachine");
if(mes==null || mes.length ==0)
{
return;
}
VirtualMachine vm = (VirtualMachine) mes[0];
VirtualMachineConfigInfo vminfo = vm.getConfig();
VirtualMachineCapability vmc = vm.getCapability();
vm.getResourcePool();
System.out.println("Hello " + vm.getName());
System.out.println("GuestOS: " + vminfo.getGuestFullName());
System.out.println("Multiple snapshot supported: " + vmc.isMultipleSnapshotsSupported());
si.getServerConnection().logout();
}
}
the error is related to expecting the ssl certificate.
Exception in thread "main" java.rmi.RemoteException: VI SDK invoke exception:javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address 10.100.13.36 found
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:182)
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:124)
at com.vmware.vim25.ws.VimStub.retrieveServiceContent(VimStub.java:1521)
at com.vmware.vim25.mo.ServiceInstance.<init>(ServiceInstance.java:85)
at com.vmware.vim25.mo.ServiceInstance.<init>(ServiceInstance.java:69)
at com.vmware.vim25.mo.samples.HelloVM.main(HelloVM.java:16)
As i confirmed the program error is no relation to vmware and it is related to certificate.
the first step i have done is creating the jks file using the following command
c:/java/jre/bin>keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
it creates the keystore.jks in the bin folder.
i have to understand how to refer this keystore.jks in the java program.(i am having less knowledge on this...sorry)
how to generate the certificate and what is the meaning of importing the certificate and exporting the certificate.
In my case do i need to import or export..
Initially i posted the question one person..
he answered as " At high level, you will need the server certificate into your keystore and include the keystore in the JVM parameter"
Please clarify my doubts and throw some light on this..
thank you.