Request: expose the certificate the server presented on a TLS interfaces.rawSocket connection (signature for illustration):
String getPeerCertificate() // PEM of the server's leaf certificate, null before the handshake completes
Use case: bridge-free Google TV / Android TV control. The TV's remote protocol runs over TLS with a client certificate, and pairing hashes the TV's RSA public key with the code shown on screen, so the driver needs the TV's certificate.
The rest of the protocol works in a driver today (2.5.2.138, C-7, against a real Android TV box): client-certificate TLS, RSA key generation, a self-signed certificate built in the driver, pairing, and the remote session. The TV's certificate is currently read from a hand-built TLS 1.2 ClientHello sent over a plain socket, where the Certificate message comes back in the clear. Under TLS 1.3 it is encrypted, so this stops working once a TV refuses TLS 1.2.
Related rawSocket behaviour:
certificateandprivateKeywithoutcaCertificatemakeconnect()throwNullPointerException. WithignoreSSLIssues: trueany PEM certificate works there, so it's a placeholder. Could it be optional?- When the server rejects the handshake,
socketStatus()is called about every 6 ms with the same "Connection has closed" error untilclose(). - With no
tlsVersion, the socket negotiates TLS 1.2 with a server that offers 1.3.httpGetandasynchttpGetnegotiate 1.3 with a server offering both. - When a TLS server closes the connection cleanly,
socketStatus()is not called andparse()stops; a driver needs its own idle timer. close()called from insideparse()logsjava.lang.RuntimeException: java.lang.InterruptedException (method socketStatus)as an error, with no line number, even when the driver'ssocketStatuscatches all exceptions. A close scheduled withrunInMillisavoids it on an established session, but not after the server has rejected a pairing code.
@gopher.ny for your consideration.