Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:25:01+00:00 2026-06-09T15:25:01+00:00

i use a tomcat http connector with client-authentification. If a client start a new

  • 0

i use a tomcat http connector with client-authentification. If a client start a new connection to my server and sends his certificate, can i get the certificate and read the common name from the incoming certificate out in my java code. If yes, how?

thanks
adi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:25:02+00:00Added an answer on June 9, 2026 at 3:25 pm

    You can get the client certificate chain by getting the javax.servlet.request.X509Certificate attribute on your HttpServletRequest. This is an array of X509Certificates where the first one (position 0) is the actual client certificate (the rest of the chain may be present if intermediate CA certificates are required).

    X509Certificate certs[] = 
        (X509Certificate[])req.getAttribute("javax.servlet.request.X509Certificate");
    // ... Test if non-null, non-empty.
    
    X509Certificate clientCert = certs[0];
    
    // Get the Subject DN's X500Principal
    X500Principal subjectDN = clientCert.getSubjectX500Principal();
    

    You can then get the various RDNs (relative distinguished name) in this principal (e.g. CN) as described in this answer:

    import javax.naming.ldap.LdapName;
    import javax.naming.ldap.Rdn;
    
    String dn = subjectDN.getName();
    LdapName ldapDN = new LdapName(dn);
    for(Rdn rdn: ldapDN.getRdns()) {
        System.out.println(rdn.getType() + " -> " + rdn.getValue());
    }
    

    (You could also use BouncyCastle’s X509Name to get each RDN.)

    In an X.509 certificate, the Subject DN is an ordered sequence of RDNs, each of which is a set of AVAs (Attribute Value Assertions), for example CN=... or O=.... In principle, there can be multiple AVAs per RDN, which would cause problems here, but this is very rare. You can almost assume that there is only one AVA per RDN. (Perhaps this answer might be of interest.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to get Tomcat to use BoneCP as a connection pool because DBCP
How Can I use my system as a tomcat server ? Like tomcat server
I use SpringSource Tool Suite 3.0.1, Tomcat server 7.0.21, maven-2.2.1. I successfully built my
My server.xml looks like the following: <!--The connectors can use a shared executor, you
We have an Tomcat server where we're trying to log the HTTP version which
I have a Tomcat Server with 250 connection threads. When I simulate concurrent file
I have to connect to server(servlet on tomcat) always running and process the http
What do I use if I need something like Tomcat server that is always
I use Tomcat 7 on Windows XP. I have a directory with static files
We use Tomcat for our java web application. There is a properties file under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.