Solved

Multiple certs with same alias in keystore causes problem

Posted on 2011-03-03
9
2,281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:endasil
ID: 35030479
Yes that one enumerates duplicated aliases.
0
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example issues from command prompt 10 85
Fast way to search item into Java Array (Rhino compatible) 2 47
Html split(text) 2 49
Java array 21 150
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

734 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