try {
final SSLSocket sslSocket = (SSLSocket)SSLSocketFactory.getDefault().createSocket();
Timber.e("RAWR: BEFORE CONNECT");
sslSocket.connect(new InetSocketAddress("192.168.1.90", 8443));
Timber.e("RAWR: AFTER CONNECT");
final SSLSession session = sslSocket.getSession();
Timber.e("RAWR: AFTER GET SESSION");
for (Certificate certificate : session.getPeerCertificates()) {
Timber.e("RAWR found cert " + certificate);
}
} catch (SSLPeerUnverifiedException peer) {
Timber.e("RAWR: UNVERIFIED PEER %S", peer.getMessage());
} catch (IOException e) {
Timber.e(e, "RAWR IOE %s", e.getMessage());
}
I want to DOWNLOAD the certificates using the getPeerCertificates() but it throws SSLPeerUnverifiedException before it can get the certs.
The environments I'm dealing with have 100% self-signed certificates and they CANNOT be loaded on device before hand. The idea is customers do not have to load this themselves, and the app itself should download it and prompt the user whether to accept it or not.