How to fix Unirest General SSLEngine problem


I tried to post data to a rest service using Unirest ( But when I tried to post to an HTTPS url, I got the following error: General SSLEngine problem
PKIX path building failed: unable to find valid certification path to requested target unable to find valid certification path to requested target

To fix this, you could use the following code:

private CloseableHttpAsyncClient createSSLClient() {
    TrustStrategy acceptingTrustStrategy = new TrustStrategy() {

        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
	    return true;

    SSLContext sslContext = null;
    try {
        sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
    } catch (Exception e) {
        LOGGER.error("Could not create SSLContext");

    return HttpAsyncClients.custom()

Then, you need to execute the code below before using Unirest itself:


Hopefully this works for you too. Enjoy.

Add comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Tag Cloud