Smack 4.2.3. X.509 Authentication problem

Hi i have problem with implementation certificate bases authentication.
I got certificate which i took from the server and put it into keystore.
I put the code bellow:

private void createSSLContext(Certificate certificate, XMPPTCPConnectionConfiguration.Builder builder) throws KeyStoreException,
NoSuchAlgorithmException, KeyManagementException, UnrecoverableKeyException, CertificateException, IOException {
KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
trustStore.load(null, null);
trustStore.setCertificateEntry(“ca”, certificate);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustStore);

SSLContext sslContext = SSLContext.getInstance(TLSUtils.TLS);
sslContext.init(null, tmf.getTrustManagers(), null);
builder.setCustomSSLContext(sslContext);
builder.setSocketFactory(sslContext.getSocketFactory());

}

I catch next exception:
javax.net.ssl.SSLHandshakeException: Handshake failed at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:374) at com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl.java:598) at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:560)

Server logs:
Received invalid XML (not well-formed (invalid token)) 194 bytes: ____�_�__2_�CO��~%L�� +jyb�΂�d��3���,�+�,�/�0_���� �_�3_9_2_8����_/_5___�_d_________ _4_2_ ___________ ___________________________________ _ ________________________________ [128]

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.