Apache HttpClient 4.3 et x509 certificat du client pour authentifier

maintenant je cherche une solution en ce qui concerne la tâche de la façon de réécrire obsolète solution côté client certificat x509 authentification via HttpComponentsMessageSender (non pertinents).

Par exemple, obsolète solution est:

    SSLSocketFactory lSchemeSocketFactory = new SSLSocketFactory(this.keyStore, this.keyStorePassword);
    Scheme sch = new Scheme("https", 443, lSchemeSocketFactory);

    DefaultHttpClient httpClient = (DefaultHttpClient)getHttpClient();
    httpClient.getConnectionManager().getSchemeRegistry().register(sch);

Comme nouvelle solution avec CloseableHttpClient je suis en utilisant:

    SSLContextBuilder sslContextBuilder = SSLContexts.custom()
            //this key store must contain the key/cert of the client
            .loadKeyMaterial(keyStore, keyStorePassword.toCharArray());

    if (trustStore != null) {
        //this key store must contain the certs needed and trusted to verify the servers cert
        sslContextBuilder.loadTrustMaterial(trustStore);
    }

    SSLContext sslContext = sslContextBuilder.build();

    LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);

    //Create a registry of custom connection socket factories for supported
    //protocol schemes /https
    Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
            .register("https", sslsf)
            .register("http", new PlainConnectionSocketFactory())
            .build();

    PoolingHttpClientConnectionManager connPoolControl =
            new PoolingHttpClientConnectionManager(socketFactoryRegistry);
    setConnPoolControl(connPoolControl);
    getClientBuilder().setSSLSocketFactory(sslsf);

Je reçois toujours 403 interdit à partir du serveur. Mais quand j'utilise "obsolète" version de la solution, elle fonctionne très bien. SSL certificat est signé Thawte.

Une idée?
Grâce

OriginalL'auteur Tomas Hanus | 2014-03-24