Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<jboss.snapshots.repo.id>jboss-snapshots-repository</jboss.snapshots.repo.id>
<jboss.snapshots.repo.url>https://s01.oss.sonatype.org/content/repositories/snapshots/</jboss.snapshots.repo.url>

<quarkus.version>3.2.0.Final</quarkus.version>
<quarkus.build.version>3.2.0.Final</quarkus.build.version>
<quarkus.version>3.2.2.Final</quarkus.version>
<quarkus.build.version>3.2.2.Final</quarkus.build.version>

<project.build-time>${timestamp}</project.build-time>

Expand Down Expand Up @@ -74,8 +74,10 @@
<cxf.undertow.version>3.3.10</cxf.undertow.version>
<dom4j.version>2.1.3</dom4j.version>
<h2.version>2.2.220</h2.version>
<hibernate-orm.plugin.version>6.2.5.Final</hibernate-orm.plugin.version>
<hibernate.c3p0.version>6.2.5.Final</hibernate.c3p0.version>
<!-- FIXME Temporarily override Hibernate version to fix https://hibernate.atlassian.net/browse/HHH-16905; before removing, check https://github.com/quarkusio/quarkus/blob/<version>/bom/application/pom.xml -->
<hibernate-orm.version>6.2.7.Final</hibernate-orm.version>
<hibernate-orm.plugin.version>6.2.7.Final</hibernate-orm.plugin.version>
<hibernate.c3p0.version>6.2.7.Final</hibernate.c3p0.version>
<infinispan.version>14.0.13.Final</infinispan.version>
<infinispan.protostream.processor.version>4.6.2.Final</infinispan.protostream.processor.version>

Expand Down Expand Up @@ -504,6 +506,11 @@
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-c3p0</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public enum ClientAuth {
public static final Option HTTPS_PROTOCOLS = new OptionBuilder<>("https-protocols", String.class)
.category(OptionCategory.HTTP)
.description("The list of protocols to explicitly enable.")
.defaultValue("TLSv1.3")
.defaultValue("TLSv1.3,TLSv1.2")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to mitigate quarkusio/quarkus#34468 and basically replicate the previous behaviour where TLSv1.2 worked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, as the current NIST SP 800-52 Rev. 2 guideline recommends to enable TLSv1.3 alongside TLSv1.2, so clients can choose the "better" protocol on their capabilities.

.build();

public static final Option HTTPS_CERTIFICATE_FILE = new OptionBuilder<>("https-certificate-file", File.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@
import static org.keycloak.quarkus.runtime.configuration.mappers.PropertyMapper.fromOption;

final class ConfigKeystorePropertyMappers {
private static final String SMALLRYE_KEYSTORE_PATH = "smallrye.config.source.keystore.kc-default.path";
private static final String SMALLRYE_KEYSTORE_PASSWORD = "smallrye.config.source.keystore.kc-default.password";


private ConfigKeystorePropertyMappers() {
}

public static PropertyMapper[] getConfigKeystorePropertyMappers() {
return new PropertyMapper[] {
fromOption(ConfigKeystoreOptions.CONFIG_KEYSTORE)
.to("smallrye.config.source.keystore.kc-default.path")
.to(SMALLRYE_KEYSTORE_PATH)
.transformer(ConfigKeystorePropertyMappers::validatePath)
.paramLabel("config-keystore")
.build(),
fromOption(ConfigKeystoreOptions.CONFIG_KEYSTORE_PASSWORD)
.to("smallrye.config.source.keystore.kc-default.password")
.to(SMALLRYE_KEYSTORE_PASSWORD)
.transformer(ConfigKeystorePropertyMappers::validatePassword)
.paramLabel("config-keystore-password")
.build(),
Expand All @@ -36,12 +39,17 @@ public static PropertyMapper[] getConfigKeystorePropertyMappers() {
}

private static Optional<String> validatePath(Optional<String> option, ConfigSourceInterceptorContext context) {
ConfigValue path = context.proceed("smallrye.config.source.keystore.kc-default.path");
ConfigValue path = context.proceed(SMALLRYE_KEYSTORE_PATH);
boolean isPasswordDefined = context.proceed(SMALLRYE_KEYSTORE_PASSWORD) != null;

if (path == null) {
throw new IllegalArgumentException("config-keystore must be specified");
}

if (!isPasswordDefined) {
throw new IllegalArgumentException("config-keystore-password must be specified");
}

Optional<String> realPath = Optional.of(String.valueOf(Paths.get(path.getValue()).toAbsolutePath().normalize()));
if (!Files.exists(Path.of(realPath.get()))) {
throw new IllegalArgumentException("config-keystore path does not exist: " + realPath.get());
Expand All @@ -50,11 +58,17 @@ private static Optional<String> validatePath(Optional<String> option, ConfigSour
}

private static Optional<String> validatePassword(Optional<String> option, ConfigSourceInterceptorContext context) {
ConfigValue password = context.proceed("smallrye.config.source.keystore.kc-default.password");
boolean isPasswordDefined = context.proceed(SMALLRYE_KEYSTORE_PASSWORD).getValue() != null;
boolean isPathDefined = context.proceed(SMALLRYE_KEYSTORE_PATH) != null;

if (password == null) {
if (!isPasswordDefined) {
throw new IllegalArgumentException("config-keystore-password must be specified");
}

if (!isPathDefined) {
throw new IllegalArgumentException("config-keystore must be specified");
}

return option;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void testUnknownQuarkusBuildTimePropertyApplied(LaunchResult result) {
}

@Test
@Launch({ "start", "--http-enabled=true", "--hostname-strict=false", "--config-keystore=keystore" })
@Launch({ "start", "--http-enabled=true", "--hostname-strict=false", "--config-keystore=../../../../src/test/resources/keystore" })
Copy link
Contributor

@Pepo48 Pepo48 Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, this change was necessary because the invalid keystore path exception would take a precedence?

I haven't gone through the recent smallrye-keystore changes, but this might indicate that there are some improvements when it comes to exception handling, so our custom property validation might be redundant to some extent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, this change was necessary because the invalid keystore path exception would take a precedence?

Yes but it still triggered our custom validation, not anything in SmallRye.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok then, thanks for clarification.

@Order(10)
void testMissingSmallRyeKeyStorePasswordProperty(LaunchResult result) {
CLIResult cliResult = (CLIResult) result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ HTTP/TLS:
value is set, it defaults to 'BCFKS'.
--https-port <port> The used HTTPS port. Default: 8443.
--https-protocols <protocols>
The list of protocols to explicitly enable. Default: TLSv1.3.
The list of protocols to explicitly enable. Default: TLSv1.3,TLSv1.2.
--https-trust-store-file <file>
The trust store which holds the certificate information of the certificates to
trust.
Expand Down