I have written a program attempting simple communication with a VCO appliance using the REST web services API. Here is the code I am running:
package com.vmware.vco;
import java.net.URI;
import java.net.URISyntaxException;
import com.vmware.o11n.sdk.rest.client.DefaultVcoSessionFactory;
import com.vmware.o11n.sdk.rest.client.SsoAuthenticator;
import com.vmware.o11n.sdk.rest.client.VcoSession;
import com.vmware.o11n.sdk.rest.client.VcoSessionFactory;
import com.vmware.o11n.sdk.rest.client.authentication.Authentication;
import com.vmware.o11n.sdk.rest.client.authentication.UsernamePasswordAuthentication;
import com.vmware.o11n.sdk.rest.client.examples.AbstractParams;
import com.vmware.o11n.sdk.rest.client.services.ExecutionContextBuilder;
import com.vmware.o11n.sdk.rest.client.services.ExecutionService;
import com.vmware.o11n.sdk.rest.client.services.WorkflowService;
import com.vmware.o11n.sdk.rest.client.stubs.ExecutionContext;
import com.vmware.o11n.sdk.rest.client.stubs.Workflow;
public class ConnectionTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
VcoSession session;
System.out.println("starting test");
try {
session = DefaultVcoSessionFactory.newLdapSession(new URI(
"https://10.25.49.38:8281/api/"), "vcoadmin", "vcoadmin");
// create the services
WorkflowService workflowService = new WorkflowService(session);
ExecutionService executionService = new ExecutionService(session);
// find a workflow by ID
Workflow workflow = workflowService.getWorkflow("1231235");
// create an ExecutionContext from the user's input
ExecutionContext context = new ExecutionContextBuilder()
.addParam("name", "Jerry").addParam("age", 18).build();
} catch (URISyntaxException e) {
e.printStackTrace();
}
System.out.println("Exiting test");
}
}
When the statement
Workflow workflow = workflowService.getWorkflow("1231235"); is executed I am getting the following exception:
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error: peer not authenticated; nested exception is javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:453)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
at com.vmware.o11n.sdk.rest.client.services.AbstractService.getObjectAppending(AbstractService.java:64)
at com.vmware.o11n.sdk.rest.client.services.WorkflowService.getWorkflow(WorkflowService.java:40)
at com.vmware.vco.ConnectionTest.main(ConnectionTest.java:32)
As far as I can tell the creation of the session object worked just fine. The exception appears to have something to do with the certificate. I have imported the certificate from the VCO appliance into my cacerts file but I still get the exception. I cannot find any information in the Developing a Web Services Client for VMware vCenter Orchestrator document relating to this issue. If anyone has seen this and knows the resolution please let me know.