Skip to content

Commit

Permalink
Merge pull request payara#5395 from JamesHillyard/FISH-5693
Browse files Browse the repository at this point in the history
FISH-5693 Updated multiple keystore delimiter to be OS dependent
  • Loading branch information
JamesHillyard committed Oct 11, 2021
1 parent 31ff004 commit 9befc0d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.security.KeyPair;
import java.security.cert.X509Certificate;

Expand All @@ -58,16 +57,20 @@
public class MultipleKeystoresConfigurationTest {

@Test
public void createAdditionalKeystore() throws IOException {
public void createAdditionalKeystore() {
KeyPair clientKeyPair = SecurityUtils.generateRandomRSAKeys();
X509Certificate clientCertificate = SecurityUtils.createSelfSignedCertificate(clientKeyPair);
String path = SecurityUtils.createTempJKSKeyStore(clientKeyPair.getPrivate(), clientCertificate);

//Used so the path is correct when run in the cli command
path = path.replace("\\", "\\\\");
path = path.replace(":", "\\:");

CliCommands.payaraGlassFish("create-jvm-options", "\"-Dfish.payara.ssl.additionalKeyStores="+path+"\"");
}

@Test
public void createNewNetworkListener(){
public void createNewNetworkListener() {
CliCommands.payaraGlassFish("create-protocol", "--securityenabled=true", "--target=server-config", "wibbles-protocol");
CliCommands.payaraGlassFish("create-http", "--defaultVirtualServer=server", "--target=server-config", "wibbles-protocol");
CliCommands.payaraGlassFish("create-network-listener", "--address=0.0.0.0", "--listenerport=8282", "--protocol=wibbles-protocol", "wibbles");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,12 @@ protected void checkAdditionalTrustAndKeyStores() throws IOException, XMLStreamE
if (additionalTrustandKeyStores.containsKey("additionalKeyStores")) {
logger.log(Level.INFO,
"The passwords of additional KeyStores {0} have not been changed - please update these manually to continue using them.",
Arrays.toString(additionalTrustandKeyStores.get("additionalKeyStores").split(":(?!\\\\)")));
Arrays.toString(additionalTrustandKeyStores.get("additionalKeyStores").split(File.pathSeparator)));
}
if (additionalTrustandKeyStores.containsKey("additionalTrustStores")) {
logger.log(Level.INFO,
"The passwords of additional TrustStores {0} have not been changed - please update these manually to continue using them.",
Arrays.toString(additionalTrustandKeyStores.get("additionalTrustStores").split(":(?!\\\\)")));
Arrays.toString(additionalTrustandKeyStores.get("additionalTrustStores").split(File.pathSeparator)));
}
} catch (ParserConfigurationException | SAXException exception) {
logger.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected ArrayList<KeyStore> getKeystore(String pass) throws IOException {
String keystoreFile = (String) attributes.get("keystore");
String[] additionalKeyStoreFileNames = null;
if(attributes.get(ADDITIONAL_KEY_STORES_ATTR) != null){
additionalKeyStoreFileNames = ((String) attributes.get(ADDITIONAL_KEY_STORES_ATTR)).split(":");
additionalKeyStoreFileNames = ((String) attributes.get(ADDITIONAL_KEY_STORES_ATTR)).split(File.pathSeparator);
}

if (logger.isLoggable(Level.FINE)) {
Expand Down Expand Up @@ -299,7 +299,7 @@ protected KeyStore[] getTrustStore() throws IOException {

String[] additionalTrustStoreFileNames = null;
if(attributes.get(ADDITIONAL_TRUST_STORES_ATTR) != null){
additionalTrustStoreFileNames = ((String) attributes.get(ADDITIONAL_TRUST_STORES_ATTR)).split(":");
additionalTrustStoreFileNames = ((String) attributes.get(ADDITIONAL_TRUST_STORES_ATTR)).split(File.pathSeparator);
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Truststore file= {0}", truststore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static java.util.logging.Level.FINEST;
import static java.util.logging.Level.WARNING;

import java.io.File;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -409,10 +410,10 @@ private void initStores(char[] keyStorePassIn, char[] trustStorePassIn) {
String[] additionalKeyStoreFileNames = null;
String[] additionalTrustStoreFileNames = null;
if(additionalKeyStoreFileName != null){
additionalKeyStoreFileNames = additionalKeyStoreFileName.split(":");
additionalKeyStoreFileNames = additionalKeyStoreFileName.split(File.pathSeparator);
}
if(additionalTrustStoreFileName != null){
additionalTrustStoreFileNames = additionalTrustStoreFileName.split(":");
additionalTrustStoreFileNames = additionalTrustStoreFileName.split(File.pathSeparator);
}

initStores(keyStoreFileName, keyStorePass, trustStoreFileName, trustStorePass, additionalKeyStoreFileNames, additionalTrustStoreFileNames);
Expand Down

0 comments on commit 9befc0d

Please sign in to comment.