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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:13:25+00:00 2026-05-25T03:13:25+00:00

Ok, I exported all the certs in my browser by doing this: Tools, Options…,

  • 0

Ok, I exported all the certs in my browser by doing this: Tools, Options…, Advanced, Encryption, View Certificates, Your Certificates, Backup All… (this is in Firefox).

There are 4 certs in the list of Certificates, two are under one Name and have distinct serial numbers, and the other two are under a different name and have two other distinct serial numbers. So, in summary, there are four certs, two pair have the same name but distinct serial numbers.

If I were to import this p12 file into another browser on another machine I get all four certs (as expected).

— BUT —

When I open the p12 file with the java.security.* package and look at the size(), it shows only two certs in the p12 file. When I loop through the aliases I see only two certs. Is there something in the KeyStore object that allows me access to all four certs? It’s tough because the aliases are the same for the two pairs, only the serial numbers are different. Thanks in advance for any help you can provide.

  • 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-05-25T03:13:25+00:00Added an answer on May 25, 2026 at 3:13 am

    Ok, to answer my own ancient question… I learned that Java is not that good at reading p12 files. It creates a hashmap using the alias of each certificate as the key so if there are two certs with the same alias, Java will clobber the first cert with the second cert with the same alias (key), rsulting in only one cert per alias.

    When importing the certs into a browser, the browser takes all the entries in the p12 file (not caring about the aliases).

    The way I worked around this was to use Java runtime exec functionality to call openssl and pipe the output of each cert into a String and using that string to create an X509Certificate. Here’s some sample code (I cannot copy and paste as my dev box is not internet connected):

    private ArrayList<X509Certificate> parseCerts( String fileName, String pwd ) {
       ArrayList certsFromP12File = new ArrayList();
       String cmdLine = "/usr/bin/openssl pkcs12 -info -in " + fileName + " -clcerts -nokeys -passin pass:" + pwd;
    
       String line;
    
       Process p = Runtime.getRuntime().exec( cmdLine );
    
       BufferedReader input = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
    
       boolean readingCert = false;
       boolean gotCertToProcess = false;
       String certString;
    
       while ((line=input.readLine()) != null ) {
          if ( line.contains("-----BEGIN CERTIFICATE-----") ) {
             readingCert = true;
          }
          if ( readingCert ) {
             certString += line + System.getProperty("line.separator");
          }
          if ( line.contains("-----END CERTIFICATE-----") ) {
             readingCert = false;
             getCertToProcess = true;
          }
          if ( gotCertToProcess ) {
             X509Certificate cert = null;
             byte[] cert_bytes = certString.getBytes();
             ByteArrayInputStream certInputStream = new ByteArrayInputStream(cert_bytes);
             cert = (X509Certificate) CertificateFactory.getInstance("X509").generateCertificate( certInputStream );
             certsFromP12File.add( cert );
             gotCertToProcess = false;
             certString = "";
          }
       }
       input.close();
    
       return certsfromP12File;
    }
    

    Hope that helps others. 🙂

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

Sidebar

Related Questions

I've got a Windows DLL that I wrote, written in C/C++ (all exported functions
I have this exported file of some weird (standard for this industry!) format, which
I'm trying to get all refs from an external repository when cloning. I exported
I have a shed load of 'aps_developer_identity.cer' certificates exported from iPhone Developer portal. They
I made this very simple 3D model exported to .x format with Google SketchUp,
This question seems to have been asked a lot but all were trying to
I created a design for my website in Photoshop and exported all images as
I'm using the DisplayTag library 1.2 and on the export all links are exported
I have a ssrs 2008 report which when exported to word gives all sorts
We have a repository that was exported from subversion into git. This repository is

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.