I have a circumstance where I need to store one or more public keys for use in authentication. I would like to store them in a KeyStore as TrustedCertificates - is there a way to do this, ideally using standard java.security classes?
I have seen that I can generate certificates with Bouncycastle, but most examples seem to show examples of chains of trust, whereas in my case I have individual trusted keys. Also, all the examples I have seen deal with key-pairs, but I am only interested in the set of public keys provided. Is it possible to create a certificate containing only a public key?
Short answer: you cannot create certificate without private key.
Long answer: google "java create self signed certificate programmatically", e.g.: https://www.mayrhofer.eu.org/post/create-x509-certs-in-java/