Apache HttpClient - POST to https url secure?
<p>i want to do a <code>HTTP POST</code> request, which is secured by ssl.</p>

<p>the client is my java program, which is posting to a https-url (https:// ...). the certificate of the website is verified, i am using Apache HttpClient 4.5.1
with a normal post-request and a custom httpclient.</p>

<pre><code>    HttpContext context = HttpClientContext.create();
    PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
    cm.setDefaultMaxPerRoute(MAX_CONNECTIONS_PER_ROUTE);
    cm.setMaxTotal(MAX_TOTAL_CONNECTIONS);
    CloseableHttpClient client = HttpClients.custom()
            .setConnectionManager(cm)
            .build();
    HttpContext context = HttpClientContext.create();

    HttpPost login = new HttpPost("https://example.org"); // example url
    login.addHeader("Content-Type", "application/json; charset=UTF-8");
    login.addHeader("Accept", "application/json; charset=UTF-
    login.setEntity(new StringEntity(loginData, ContentType.create("application/json", "UTF-8")));

    JSONResponseHandler&lt;JSONObject&gt; rh = new JSONResponseHandler&lt;&gt;();
    JSONObject test = client.execute(login, rh, context);
</code></pre>

<p>is this sufficend to get a ssl-secured connection or do i have to work with <code>KeyStore</code>, <code>SSLContext</code> and <code>SSLConnectionFactory</code>?</p>

<p>if i have to use those, how would i do this in an efficent way. i only saw examples how to allow self-signed certificates.</p>