I need some help with Android OkHttp client/server application. The problem is the following: it seems like my Android client doesn't send any certificate to the server after receiving a Certificate Request. Here is my Android code:
private static SSLContext getContext(InputStream keystoreInputStream){
SSLContext sslContext = null;
try{
//==========
try {
// The keystore contains the CA cert and the Client cert
KeyStore keyStore = KeyStore.getInstance("PKCS12");
try {
keyStore.load(keystoreInputStream, "MYPASS".toCharArray());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
ksIn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
sslContext = SSLContext.getInstance("TLS");
String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
tmf.init(keyStore);
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("X509");
keyManagerFactory.init(keyStore, "MYPASS".toCharArray());
sslContext.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), null);
} catch (Exception e) {
e.printStackTrace();
}
//==========
}catch (Exception e){
}
return sslContext;
}
And This is the wireshark session between Android Client (192.168.1.72) and Server (192.168.1.79):
Wireshark TLS session - CLIENT CERTIFICATE (empty)
As you can see the Server sends a Certificate Request but the client sends Certificate with lenght 0. Can you explain me how can I fix this? Thanks.