How to read certificates from the browser's keystore databases from both IE and Firefox

Hello experts,

I have a few questions on importing certificates from Browsers: IE and Firefox.

I need to read the certificates from the browser with my servlet. Basically some users browsers have certificates installed in there that are assigned to them. I need to obtain that certificate, convert it to a base64 string and pass it to a SOAP service call to do SSO for that user with that cert. I have written most of it including a class that takes base64 string certificate, convert to a X509 object so that I can parse all the information from it.

On Firefox there are 2 files for their trustore databases, key3.db and cert8.db. I wonder which file would contain the certificates installed on the browser.

Reading java documentation I found out that I can initialize a keystore object with one of those files.

So I've tried something like this method loadStore. I need the password to the file to be able to open it and its type. Hence, how do I get the password for that file? Where does Firefox stores it or is there a standard password for it. In some research docs I found the password should be something like 'changeit'.

Then you have the store type which can be JCEKS, JKS, x.jceks.

So how do I determine which store type I have?

Also, how can I do the same with IE?

The idea is to be able to programmatic import certificates installed on the localbox browser.

For a Linux system, Firefox has a random folder name which is inside each user. Is there any enviroment variable that can give me that? For instance on this box the folder is /home/user1/.mozilla/firefox/g5vp07oz.default  The random folder name is "something".default under $HOME/.mozilla/firefox.

On Internet Explorer, where would the certificate database be? How do I initialize a KeyStore object reading from those DB files?
// loadStore method
public static KeyStore loadStore(String file, String pass, String type) throws Exception {
        KeyStore ks = KeyStore.getInstance(type);
        FileInputStream is = null;
        if (file != null && !file.equals("NONE")) {
            is = new FileInputStream(file);
        ks.load(is, pass.toCharArray());
        return ks;

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

People attempting to answer this might like to look at the related question:
Mick BarryJava DeveloperCommented:
Pretty sure they use proprietry format. As I mentioned in your other question I don't believe it can be done.

CarlosScheideckerAuthor Commented:
It seems to me that there is a solution, albeit not elegant:

It is here

The problem is that you need to load the NSS libraries.

However, looking insider sunpcks11.jar  that there might be a better solution.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mick BarryJava DeveloperCommented:
Sorry I told you earlier you would need a native solution, thought you want a Java only solution :)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.