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 8818899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:13:12+00:00 2026-06-14T05:13:12+00:00

In Java How do you extract issued to or user from a SSL cert

  • 0

In Java How do you extract “issued to” or user from a SSL cert within an HttpRequest?

what I’m working with:

 Object certChain = request
    .getAttribute("javax.servlet.request.X509Certificate");
if (certChain != null)
{
  X509Certificate certs[] = (X509Certificate[]) certChain;
  X509Certificate cert = certs[0];
  String user = cert.getSubjectDN().getName();
}
  • 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-14T05:13:13+00:00Added an answer on June 14, 2026 at 5:13 am

    Here’s the code to extract the “Issued To” aka Subject for a cert within an httprequest,

    import java.security.cert.X509Certificate;
    import javax.naming.InvalidNameException;
    import javax.naming.ldap.LdapName;
    import javax.naming.ldap.Rdn;
    
    X509Certificate[] certs = (X509Certificate[])request.getAttribute("javax.servlet.request.X509Certificate");
    if ((certs == null) || (certs.length == 0)) {
       return null;
    }
    
    String name = certs[0].getSubjectX500Principal().getName(); // if you are looking for issuer then use cert[0].getIssuerX500Principal().getName();
    LdapName ldapName = null;
    try {
       ldapName = new LdapName(name);
    } catch (InvalidNameException e) {
       throw new RuntimeException(e);
    }
    
    for (Rdn rdn : ldapName.getRdns()) {
       String type = rdn.getType();
       if ("CN".equals(type)) { 
            String issuedTo = (String)rdn.getValue();
       }
    }
    

    JDK 6 has the API getSubjectX500Prinicpal() in it’s rt.jar locally, not sure about the previous versions,
    enter image description here

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

Sidebar

Related Questions

How to extract the path c:/documents and settings/user using Java... Is there any method??
im trying to extract some files from a jar-file downloaded using java-webstart. below code
I'm looking for a parser that can extract methods from a java class (static
I've a requirement where I have to extract metrics from different Java projects (configured
i'm working with java to extract values of a time column in table in
I'm using Java XPath API to extract content from a xhtml file. I'm pasring
I need to extract some specific functionality from a large legacy Java codebase, in
Possible Duplicate: How do I extract a tar file in Java? I'm working on
I'm using Mac OSX(10.7) and trying to extract java file from a android apk.
I have a Java application that will parse html pages and extract data from

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.