rlevas commented on a change in pull request #56: KNOX-1756 - Knox Gateway TLS
Keystore and Alias Should be Configurable
URL: https://github.com/apache/knox/pull/56#discussion_r259081810
##########
File path:
gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java
##########
@@ -261,6 +273,39 @@ public String getLdapUrl() {
return "ldap://localhost:" +
ldapTransport.getAcceptor().getLocalAddress().getPort();
}
+ public void setupTestKeystore(GatewayConfig config, char[] password)
+ throws NoSuchAlgorithmException, CertificateException,
KeyStoreException, IOException {
+
+ String alias = config.getIdentityKeyAlias();
+
+ // Ensure parent directory exists...
+ Path keystoreFile = Paths.get(config.getIdentityKeystorePath());
+ Files.createDirectories(keystoreFile.getParent());
+
+ KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
+ kpg.initialize(2048);
+ KeyPair keyPair = kpg.generateKeyPair();
+
+ Certificate cert =
X509CertificateUtil.generateCertificate("CN=localhost,OU=Test,O=Hadoop,L=Test,ST=Test,C=US",
keyPair, 365, "SHA1withRSA");
+
+ KeyStore keyStore = KeyStore.getInstance(config.getIdentityKeystoreType());
+ keyStore.load(null, password);
+ keyStore.setCertificateEntry(alias, cert);
+ keyStore.setKeyEntry(alias, keyPair.getPrivate(), password, new
java.security.cert.Certificate[]{cert});
+ try (OutputStream out = Files.newOutputStream(keystoreFile)) {
+ keyStore.store(out, password);
+ }
+ }
+
+ public void cleanupTestKeystore(GatewayConfig config) {
+ try {
+
Files.delete(Paths.get(config.getIdentityKeystorePath()).toAbsolutePath());
Review comment:
Fixing
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services