scop / portecle

User friendly GUI application for creating, managing and examining keystores, keys, certificates, certificate requests, certificate revocation lists and more
http://portecle.sourceforge.net/
GNU General Public License v2.0
153 stars 47 forks source link

BKS_V1 Keystore not detected as BKS_V1 Keystore #46

Open scop opened 7 years ago

scop commented 7 years ago

Steps to reproduce:

Maybe there is a missing check of the STORE_VERSION. Version 0 for BKS_V1, higher for BKS.

Reported by: redirion

scop commented 7 years ago

I'm not sure what you mean by checking STORE_VERSION. Is there an API for doing that available?

FWIW, I think BC should just tell us the correct type when asked with KeyStore.getType; currently it always says BKS no matter if the store was created as BKS or BKS-V1. That way things would just work. Could you file a BC bug about this?

Original comment by: scop

scop commented 7 years ago

I have to correct myself: Version 0 is of course not BKS_V1. Version 1 is correct. To check the store version of a BKS keystore just open a DataInputStream of the keystore and read the first int. It contains the version. 1 is for BKS_V1 and higher is BKS.

Examplecode: DataInputStream dis = new DataInputStream(Test.class.getClassLoader().getResourceAsStream("certstore.bks")); int storeVersion = dis.readInt(); if(storeVersion == 1) { System.out.println("BKS_V1 keystore"); } else { System.out.println("BKS keystore with store version " + storeVersion); }

Original comment by: redirion

scop commented 7 years ago

I don't think I want to embed this low level details about key store formats inside Portecle. Having BC just tell us what it has would be the preferable approach.

Original comment by: scop