From 09a9afbb6c949d25ccf9e47c2367876812b7f487 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Tue, 15 Oct 2024 16:10:46 -0400 Subject: [PATCH] fix(config-list): allow list indices using underscores for env vars (#503) * docs(readme): correct typo * fix(config-list): allow list indices using underscores for env vars --- README.md | 4 ++-- src/main/java/io/cryostat/agent/ConfigModule.java | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7923bf4f..af91bcd4 100644 --- a/README.md +++ b/README.md @@ -188,9 +188,9 @@ and how it advertises itself to a Cryostat server instance. Properties that requ - [ ] `cryostat.agent.webclient.tls.version` [`String`]: the version of TLS used for the Agent's client SSL context. Default `TLSv1.2`. - [ ] `cryostat.agent.webclient.tls.trust-all` [`boolean`]: control whether the agent trusts all certificates presented by the Cryostat server. Default `false`. This should only be overridden for development and testing purposes, never in production. - [ ] `cryostat.agent.webclient.tls.verify-hostname` [`boolean`]: control whether the agent verifies hostnames on certificates presented by the Cryostat server. Default `true`. This should only be overridden for development and testing purposes, never in production. -- [ ] `cryostat.agent.webclient.tls.trustore.certs` [`list`]: the list of truststoreConfig objects with alias, path, and type properties for certificates to be stored in the agent's truststore. For example, 'cryostat.agent.webclient.tls.truststore.certs[0].type' would be the type of the first certificate in this list. A truststoreConfig object must contain all three properties to be a valid certificate entry. +- [ ] `cryostat.agent.webclient.tls.trustore.cert` [`list`]: the list of truststoreConfig objects with alias, path, and type properties for certificates to be stored in the agent's truststore. For example, 'cryostat.agent.webclient.tls.truststore.cert[0].type' would be the type of the first certificate in this list. A truststoreConfig object must contain all three properties to be a valid certificate entry. - [ ] `cryostat.agent.webclient.tls.truststore.type` [`String`]: the type of truststore used for the agent's client truststore. Default `JKS`. -- [ ] `cryostat.agent.webclient.tls.truststore.path` [`String`]: the filepath to the agent's webclient truststore. This takes precedent over `cryostat.agent.webclient.tls.truststore.certs` and must be configured with the truststore's pass with `cryostat.agent.webclient.tls.truststore.pass.file` or `cryostat.agent.webclient.tls.truststore.pass`. +- [ ] `cryostat.agent.webclient.tls.truststore.path` [`String`]: the filepath to the agent's webclient truststore. This takes precedence over `cryostat.agent.webclient.tls.truststore.cert` and must be configured with the truststore's pass with `cryostat.agent.webclient.tls.truststore.pass.file` or `cryostat.agent.webclient.tls.truststore.pass`. - [ ] `cryostat.agent.webclient.tls.truststore.pass.file` [`String`]: the filepath to the agent's client truststore's password - [ ] `cryostat.agent.webclient.tls.truststore.pass.charset` [`String`]: the character set used by the agent's client truststore's password. Default `utf-8`. - [ ] `cryostat.agent.webclient.tls.truststore.pass` [`String`]: the String format of the agent's client truststore's pass diff --git a/src/main/java/io/cryostat/agent/ConfigModule.java b/src/main/java/io/cryostat/agent/ConfigModule.java index 5cb3d4d9..1f245cbc 100644 --- a/src/main/java/io/cryostat/agent/ConfigModule.java +++ b/src/main/java/io/cryostat/agent/ConfigModule.java @@ -94,7 +94,7 @@ public abstract class ConfigModule { "cryostat.agent.webclient.tls.truststore.cert"; public static final Pattern CRYOSTAT_AGENT_TRUSTSTORE_PATTERN = Pattern.compile( - "^(?:cryostat\\.agent\\.webclient\\.tls\\.truststore\\.cert)\\[(?\\d+)\\]\\.(?.*)$"); + "^(?:cryostat\\.agent\\.webclient\\.tls\\.truststore\\.cert).(?\\d+).\\.(?.*)$"); public static final String CRYOSTAT_AGENT_WEBCLIENT_TLS_CLIENT_AUTH_CERT_PATH = "cryostat.agent.webclient.tls.client-auth.cert.path"; public static final String CRYOSTAT_AGENT_WEBCLIENT_TLS_CLIENT_AUTH_CERT_TYPE = @@ -378,9 +378,11 @@ public static List provideCryostatAgentWecblientTlsTruststoreC throw new IllegalArgumentException( String.format( "Invalid truststore config property name format:" - + " \"%s\". Make sure the config property" - + " matches the following pattern:" - + " 'cryostat.agent.truststore.cert[CERT_NUMBER].CERT_PROPERTY'", + + " \"%s\". Make sure the config property" + + " matches the following pattern:" + + " '" + + CRYOSTAT_AGENT_WEBCLIENT_TLS_TRUSTSTORE_CERTS + + "[CERT_NUMBER].CERT_PROPERTY'", name)); } int truststoreNumber = Integer.parseInt(matcher.group("index"));