Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BKS_V1 Keystore not detected as BKS_V1 Keystore #46

Open
scop opened this issue Nov 11, 2016 · 3 comments
Open

BKS_V1 Keystore not detected as BKS_V1 Keystore #46

scop opened this issue Nov 11, 2016 · 3 comments

Comments

@scop
Copy link
Owner

scop commented Nov 11, 2016

Steps to reproduce:

  • create a BKS_V1 keystore or create a BKS keystore and convert it to BKS_V1
  • inspect it with Keystore Report. It shows BKS_V1
  • Close Portecle.
  • Open the keystore again and inspect it with Keystore Report. It shows BKS (even though it actually is BKS_V1, as I could confirm by testing with an older Bouncycastle version).

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

Reported by: redirion

@scop
Copy link
Owner Author

scop commented Nov 11, 2016

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
Copy link
Owner Author

scop commented Nov 11, 2016

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
Copy link
Owner Author

scop commented Nov 11, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant