Solved

Multiple certs with same alias in keystore causes problem

Posted on 2011-03-03
9
2,155 Views
Last Modified: 2012-05-11
To load a certificate on my computer into java  i can use the following code:

ks = KeyStore.getInstance("Windows-My");
X509Certificate cert = (X509Certificate)ks.getCertificate(aliasKey);

The problem is that there are multiple certificates in the store with the alias auth or sign, and by passing in "auth" i simply get the first one. Is there another way of doing this that can handle multiple certificates with same alias?
0
Comment
Question by:endasil
  • 4
  • 4
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 35029673
Why would you give certs the same alias?
0
 

Author Comment

by:endasil
ID: 35029785
They are just a bunch of certs that i have imported to my computer by double clicking them, i was not the one choosing their names.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35029899
If you use

http://download.oracle.com/javase/6/docs/api/java/security/KeyStore.html#aliases()

does it enumerate them all (allowing dup aliases)?
0
 

Author Comment

by:endasil
ID: 35030479
Yes that one enumerates duplicated aliases.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 86

Expert Comment

by:CEHJ
ID: 35030535
0
 

Author Comment

by:endasil
ID: 35030623

GetCreationDate(String alias) will get the time for the first certificate with that alias in the store. How could i get the date for the second, third or fourth?

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35030812
Not sure if this is possible
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 35031098
> Is there another way of doing this that can handle multiple certificates with same alias?

no there isn't.
you'll need to copy them into a new store and give them unique names
0
 

Author Closing Comment

by:endasil
ID: 35031776
Thank you for that response objects, and thank you CEHJ for taking your time to try to help.


If any of you guys know the answer to this problem, i would be very happy. :) http://www.experts-exchange.com/Programming/Languages/Java/Q_26861809.html
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars2 challenge 6 70
nestparen challenge 4 56
topping2 challenge 13 61
solarwind tftp server 2 32
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now