spring-projects / spring-vault

Provides familiar Spring abstractions for HashiCorp Vault
https://spring.io/projects/spring-vault
Apache License 2.0
283 stars 186 forks source link

Support PEM encoded certificates and EC for private keys #688

Closed abremora closed 2 years ago

abremora commented 2 years ago

Support for PEM encoded certificates added. Although there is a parser for PEM files already available (see PemObject), I introduced a new one called PemReader. This implementation has no dependencies to RSA. This seems to be reasonable because there are more algorithms available. Further I looked for a solution to add easily more private key implementations. The result was a PrivateKeyFactory which holds a list of private key strategies (RsaPrivateKeyStrategy, EcPrivateKeyStrategy). RsaPrivateKeyStrategy is just a wrapper for KeystoreUtil.getRSAPrivateKeySpec(). To prove the concept, I quickly develop a EcPrivateKeyStrategy. That's why the support for EC is already present here. If you like to split these two features into separate PRs just give me a note.

Fixes gh-678 Fixes gh-683

mp911de commented 2 years ago

Thanks for your contribution. The pull request introduces several types to the code base, including a duplicate approach for PEM decoding.

I'm going to pick individual bits from the pull request as it makes sense to revise our certificate and private key support for PEM and DER encoding. It also makes sense to include elliptic curve support.

abremora commented 2 years ago

I am happy to support you. Please do not hesitate to contact me if you need further assistance.

mp911de commented 2 years ago

Thank you for your contribution. That's merged and polished now.