How to get the principal after a successful SSL handshake using Mina? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How to get the principal after a successful SSL handshake using Mina? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am using Mina with a SslFilter, configured with “client authentication needed”.

Once a connection is made and a handshake is done, how to get the certificate (or the principal) of the peer on the other side of the connection from my subclass of the IoHandler on the server ?

Edit: in other words, how to get the relation between a IoSession and the principal once the handshake is done and the IoHandler.sessionOpened() is called.

Answer

It looks like you can get the SSLSession using SslFilter.getSslSession(...). Then, use SSLSession.getPeerCertificateChain() to get the client certificate chain. The actual client certificate is at position 0 in that array.

We are here to answer your question about How to get the principal after a successful SSL handshake using Mina? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji