Search code examples
javasslhttpssuncom.sun.net.httpserver

How to get the ssl session when using the sun HttpsServer


I am using the com.sun.net.httpserver.HttpsServer as Https Server and want to access the SSL session.

I handle the requests in a HttpHandler. When using a plain SSLServerSocket i can access the client certificate etc. via the SSLSocket.getSession(...) method but i couldn't found such a thing in the HttpExchange parameter of the handle method inside the HttpHandler.

Is there a way to access it?


Solution

  • Cast the HttpExchange to an HttpsExchange and get the SSLSession from that.