Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Using certificate with default Bootstrap #29

Closed
painos opened this issue Oct 22, 2018 · 3 comments
Closed

Using certificate with default Bootstrap #29

painos opened this issue Oct 22, 2018 · 3 comments

Comments

@painos
Copy link

painos commented Oct 22, 2018

Certificate part work wonderfully when I make a key pair and use private key for building conf and use custom Delegate and do the following:

KeyFactory kf = KeyFactory.getInstance("DSA");
X509EncodedKeySpec keySpecX509 = new X509EncodedKeySpec(Base64.getDecoder().decode("BASE64PUBLICKEY"));
DSAPublicKey key = (DSAPublicKey) kf.generatePublic(keySpecX509);
config.update(key)

However, if I want to use --cert=[path] and the default delegate I find it really difficult to build the certification file. I have tried so many different ways to create the file and I always end up getting an error like "Caused by: java.io.IOException: Short read of DER length" or "java.security.cert.CertificateException: Could not parse certificate: java.io.IOException: Incomplete data"

So I'm asking is there a simple way to generate a valid certification file with correct info to build the public key?

@mordechaim
Copy link
Contributor

Assuming BASE64PUBLICKEY is just placeholder text.

The default bootstrap only supports X.509 certificates and in no way attempts to be a full fledged key-type detection framework.

Note: Certificates are more than just public keys. X.509 certs is the standard type generated with Java's keytool command.

Unfortunately, if you need different key types you cannot use the default bootstrap; although nothing holds you back from copying the source code and making your changes and use it as a custom bootstrap.

@painos
Copy link
Author

painos commented Oct 24, 2018

Thank you, I think I got it now. And yes it is just a placeholder.

I manged to create keypair with keytool and exported a public key cer -file. On dev machine I get private key from a keystore when generating a new conf file. Works like a charm.

I store the public key .cer in the application folder and it can be bundled with installation. Just to make sure; if for any reason I want change the keypair is it also safe to push a new public key .cer -file with rest of the updates or are there some security concerns?

@mordechaim
Copy link
Contributor

mordechaim commented Oct 24, 2018 via email

@painos painos closed this as completed Nov 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants