public static KeyStore buildKeyStore(Path certChainFile, Path keyFile, char[] keyPasswordChars) throws GeneralSecurityException {
        try {
            return doBuildKeyStore(certChainFile, keyFile, keyPasswordChars);
        } catch (KeyStoreException | NoSuchAlgorithmException | InvalidKeySpecException | CertificateException |
                KeyException | IOException | PKCSException | OperatorCreationException e) {
            throw new GeneralSecurityException(e);
        }
    }
@Test
    public void testBuildKeyStoreWithSecuredPrivateKey() throws Exception {
        final Path certChainFile = Paths.get(Resources.getResource("org/graylog2/shared/security/tls/chain.crt").toURI());
        final Path keyFile = Paths.get(Resources.getResource("org/graylog2/shared/security/tls/key-enc-pbe1.p8").toURI());
        final KeyStore keyStore = PemKeyStore.buildKeyStore(certChainFile, keyFile, "password".toCharArray());

        final Certificate[] keys = keyStore.getCertificateChain("key");
        assertThat(keys).hasSize(2);

        final Key key = keyStore.getKey("key", "password".toCharArray());
        assertThat(key.getFormat()).isEqualTo("PKCS#8");
        assertThat(key.getEncoded()).isNotEmpty();
    }