2

I am using Vertx framework for my API and have enabled https on it successfully.

For user authentication/authorization, I wan't to use client certificates i.e. who can access which APIs. The flow will:

  1. When a client makes a API hit, it presents its certificate to Vertx server. This certificate should contain username as CN.
  2. Vertx server should validate the client certificate and extract the Common name from it and then do the authorization based on this username.

How do I read the client certificate to extract cn i.e. user principal ?

Sahil
  • 53
  • 8

1 Answers1

2

When you have an io.vertx.core.http.HttpConnection you can write:

connection.sslSession().getPeerPrincipal().getName()
tsegismont
  • 8,591
  • 1
  • 17
  • 27
  • Thanks for the answer. I was able to do so. My complete scenario is that I want to do certificate authentication/authorization of my Vertx webapp i.e. the client certificate will be required and based on the cn in the client certificate, accordingly the role/authority will be decided. Any pointers for that, what will be best way to achieve this. – Sahil Dec 20 '18 at 11:52