I am aware of the the method .getPublicKey() that returns the Public key type. But, this function does not tell what type of key exchange used (EDH or RSA). If I’m right, it only return the type of the public key. My question is: How can I get the key exchange and authentication protocols used when I initiate SSL connection with a remote server ?
I am aware of the the method .getPublicKey() that returns the Public key type.
Share
From an
SSLSocketor anSSLEngine, first get theSSLSession, which will give you some information about the current SSL/TLS session.If you use
getCipherSuite(), you’ll get the cipher suite name, which contains the key exchange type (and the encryption algorithm). The cipher suites that are implemented in the Oracle JRE are listed in the SunJSSE provider documentation. You can find the naming conventions in the TLS specification: the first part afterTLS_(orSSL_for older names) and before_WITH_will tell you the key exchange algorithm (DHE_DSS,DHE_RSA,DH_anon,DH_DSS,DH_RSA,NULLorRSA): a relatively simple regular expression should be able to extract the relevant information.(You’re mentioning
getPublicKey(), but you’re not saying where you’re calling it. It would have to apply to the server’s certificate, also obtained from theSSLSession.)