feat: Implement Truststore/Keystore creation #17

Merged
MarkL4YG merged 3 commits from feat/truststorePoc into main 2024-11-23 19:24:43 +00:00
Showing only changes of commit d3ca9ae8d6 - Show all commits

View file

@ -34,8 +34,6 @@ public class KeyStoreManager {
throws JavaSecurityException {
try {
Path keystorePath = Files.createTempFile("keystore", ".jks");
String keystorePassword = "changeit";
String alias = "mykey";
// Load the keystore
KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
@ -47,12 +45,12 @@ public class KeyStoreManager {
passwordProvider.getPasswordFor(serverCert.fingerprint())
);
Certificate[] certChain = loadCertificateChain(serverCert.fullchainPath());
keystore.setKeyEntry(alias, privateKey, keystorePassword.toCharArray(), certChain);
keystore.setKeyEntry(serverCert.fingerprint(), privateKey, null, certChain);
}
// Save the keystore
try (var keystoreOut = Files.newOutputStream(keystorePath, CREATE_TRUNCATE)) {
keystore.store(keystoreOut, keystorePassword.toCharArray());
keystore.store(keystoreOut, keyStorePassphrase.toCharArray());
}
return new KeystoreResult(keystorePath);
} catch (IOException | KeyStoreException | NoSuchAlgorithmException | CertificateException e) {