Skip to content

Commit

Permalink
feat: Support of other keyring types (#2799)
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Jareš <[email protected]>
  • Loading branch information
pj892031 authored Feb 21, 2023
1 parent af38dab commit 952bf2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export const baseCategories = [
keyStoreType: {
value: 'PKCS12',
question: 'Type of the keystore:',
options: ['PKCS12', 'JKS', 'JCERACFKS'],
options: ['PKCS12', 'JKS', 'JCEKS', 'JCECCAKS', 'JCERACFKS', 'JCECCARACFKS', 'JCEHYBRIDRACFKS'],
},
trustStore: {
value: '',
Expand All @@ -301,7 +301,7 @@ export const baseCategories = [
trustStoreType: {
value: 'PKCS12',
question: 'Truststore type:',
options: ['PKCS12', 'JKS', 'JCERACFKS'],
options: ['PKCS12', 'JKS', 'JCEKS', 'JCECCAKS', 'JCERACFKS', 'JCECCARACFKS', 'JCEHYBRIDRACFKS'],
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
import org.junit.jupiter.api.Test;
import picocli.CommandLine;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.*;

class StoresTest {

Expand Down Expand Up @@ -45,8 +44,9 @@ void whenExecuteCommand_thenStoresNotInitializeExceptionIsThrown() {
ApimlConf conf = new ApimlConf();
new CommandLine(conf).parseArgs(args);
StoresNotInitializeException e = assertThrows(StoresNotInitializeException.class, () -> new Stores(conf));
assertEquals("Error while loading keystore file. Error message: ../wrongPath/localhost.truststore.p12 (No such file or directory)\n" +
"Possible solution: Verify correct path to the keystore. Change owner or permission to the keystore file.",e.getMessage());
String message = e.getMessage().replace("\\wrongPath\\", "/wrongPath/"); // replace to fix issue on windows
assertTrue(message.contains("Error while loading keystore file. Error message: ../wrongPath/localhost.truststore.p12"));
assertTrue(message.contains("Possible solution: Verify correct path to the keystore. Change owner or permission to the keystore file."));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class EurekaInstanceConfigValidator {

private static final String UNSET_VALUE_STRING = "{apiml.";
private static final char[] UNSET_VALUE_CHAR_ARRAY = UNSET_VALUE_STRING.toCharArray();
private static final String KEYRING_KEY = "JCERACFKS";

private final List<String> missingSslParameters = new ArrayList<>();
private final List<String> missingRoutesParameters = new ArrayList<>();
Expand Down Expand Up @@ -100,18 +99,24 @@ private void validateSslParameters(Ssl ssl, List<String> missingSslParameters) {
}
}

private boolean isKeyring(String in) {
if (in == null) return false;
if (!in.startsWith("JCE")) return false;
return in.endsWith("KS");
}

private void validateSsl(Ssl ssl) {
validateSslParameters(ssl, missingSslParameters);
if (isInvalid(ssl.getTrustStorePassword()) && (isInvalid(ssl.getTrustStoreType()) ||
(!isInvalid(ssl.getTrustStoreType()) && !ssl.getTrustStoreType().equals(KEYRING_KEY)))) {
(!isInvalid(ssl.getTrustStoreType()) && !isKeyring(ssl.getTrustStoreType())))) {
addParameterToProblemsList("trustStorePassword", missingSslParameters);
}
if (isInvalid(ssl.getKeyStorePassword()) && (isInvalid(ssl.getKeyStoreType()) ||
(!isInvalid(ssl.getKeyStoreType()) && !ssl.getKeyStoreType().equals(KEYRING_KEY)))) {
(!isInvalid(ssl.getKeyStoreType()) && !isKeyring(ssl.getKeyStoreType())))) {
addParameterToProblemsList("keyStorePassword", missingSslParameters);
}
if (isInvalid(ssl.getKeyPassword()) && (isInvalid(ssl.getKeyStoreType()) ||
(!isInvalid(ssl.getKeyStoreType()) && !ssl.getKeyStoreType().equals(KEYRING_KEY)))) {
(!isInvalid(ssl.getKeyStoreType()) && !isKeyring(ssl.getKeyStoreType())))) {
addParameterToProblemsList("keyPassword", missingSslParameters);
}

Expand Down

0 comments on commit 952bf2b

Please sign in to comment.