Hubspot integration with 3rd party app giving SSLHandshakeException


#1

Trying to post form submit request to hubspot, but getting ssl handshake exception.

java.lang.RuntimeException: Could not request to hubspot
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

This is my code

public void post(final List body, final String formGuId) {
HttpPost post = new HttpPost(getUri(formGuId));
post.setEntity(new StringEntity(body.toString(), Charset.forName(“UTF-8”)));
try {
hubSpot().execute(post);
} catch (IOException e) {
throw new RuntimeException(“Could not request to hubspot”, e);
}
}

private URI getUri(final String formGuId) {
    try {
        return new URIBuilder(" https://forms.hubspot.com/uploads/form/v2/portalId/formGuid").build();
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}

public HttpClient hubSpot() {
    return HttpClients.createDefault();
} 

How do we resolve this.