Skip to content

Commit 101d6ad

Browse files
committed
Default TLS protocol to TLSv1.3 and warn when not enabled
BREAKING CHANGE: Changes the default TLS protocol from "TLSv1.3,TLSv1.2" to just "TLSv1.3". Applications requiring TLSv1.2 support must now explicitly configure it using the `protocols` property (set to TLSv1.3,TLSv1.2) Adds a warning log when TLSv1.3 is not enabled in a TLS bucket configuration.
1 parent 8184ad2 commit 101d6ad

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/VertxCertificateHolder.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Collections;
88
import java.util.List;
99
import java.util.Optional;
10+
import java.util.Set;
1011
import java.util.concurrent.TimeUnit;
1112

1213
import javax.net.ssl.KeyManager;
@@ -15,6 +16,8 @@
1516
import javax.net.ssl.TrustManager;
1617
import javax.net.ssl.TrustManagerFactory;
1718

19+
import org.jboss.logging.Logger;
20+
1821
import io.quarkus.tls.TlsConfiguration;
1922
import io.quarkus.tls.runtime.config.TlsBucketConfig;
2023
import io.quarkus.tls.runtime.config.TlsConfigUtils;
@@ -114,6 +117,8 @@ public synchronized SSLOptions getSSLOptions() {
114117
options.setSslHandshakeTimeout(config().handshakeTimeout().toSeconds());
115118
options.setEnabledSecureTransportProtocols(config().protocols());
116119

120+
warnIfNotTls13(options.getEnabledSecureTransportProtocols(), name);
121+
117122
for (Buffer buffer : crls) {
118123
options.addCrlValue(buffer);
119124
}
@@ -125,6 +130,14 @@ public synchronized SSLOptions getSSLOptions() {
125130
return options;
126131
}
127132

133+
private void warnIfNotTls13(Set<String> protocols, String name) {
134+
if (!protocols.stream().map(String::toLowerCase).toList().contains("TLSv1.3".toLowerCase())) {
135+
Logger.getLogger(VertxCertificateHolder.class.getName())
136+
.warn("TLSv1.3 protocol is not enabled in TLS bucket '" + name +
137+
"'. It is *strongly* recommended to enable TLSv1.3.");
138+
}
139+
}
140+
128141
@Override
129142
public boolean isTrustAll() {
130143
return config().trustAll() || getTrustStoreOptions() == TrustAllOptions.INSTANCE;

extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/config/TlsBucketConfig.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ public interface TlsBucketConfig {
4040
/**
4141
* Sets the ordered list of enabled TLS protocols.
4242
* <p>
43-
* If not set, it defaults to {@code "TLSv1.3, TLSv1.2"}.
43+
* If not set, it defaults to {@code "TLSv1.3"}.
4444
* The following list of protocols are supported: {@code TLSv1, TLSv1.1, TLSv1.2, TLSv1.3}.
45-
* To only enable {@code TLSv1.3}, set the value to {@code to "TLSv1.3"}.
45+
* To enable {@code TLSv1.3} and {@code TLSv1.2}, set the value to {@code to "TLSv1.3, TLSv1.2"}.
4646
* <p>
4747
* Note that setting an empty list, and enabling TLS is invalid.
4848
* You must at least have one protocol.
4949
* <p>
50-
* Also, setting this replaces the default list of protocols.
5150
*/
52-
@WithDefault("TLSv1.3,TLSv1.2")
51+
@WithDefault("TLSv1.3")
5352
Set<String> protocols();
5453

5554
/**

integration-tests/vertx-http/src/test/java/io/quarkus/it/vertx/TlsProtocolVersionDefaultTestCase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@QuarkusTest
2121
public class TlsProtocolVersionDefaultTestCase {
2222

23-
@TestHTTPResource(value = "/hello", ssl = true)
23+
@TestHTTPResource(value = "/hello", tls = true)
2424
String url;
2525

2626
@Inject
@@ -55,16 +55,16 @@ void testWithWebClientRequestingTls13() {
5555

5656
@Test
5757
void testWithWebClientRequestingTls12() {
58-
// The Web client is requesting TLS 1.2, the server is exposing 1.2 and 1.3 - all good
58+
// The Web client is requesting TLS 1.2, the server is exposing 1.3 - KO
5959
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true)
6060
.setEnabledSecureTransportProtocols(Set.of("TLSv1.2"))
6161
.setKeyStoreOptions(
6262
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password"))
6363
.setTrustStoreOptions(
6464
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password"))
6565
.setVerifyHost(false));
66-
var resp = client.getAbs(url).sendAndAwait();
67-
Assertions.assertEquals(200, resp.statusCode());
66+
Throwable exception = Assertions.assertThrows(CompletionException.class, () -> client.getAbs(url).sendAndAwait());
67+
Assertions.assertTrue(exception.getCause() instanceof SSLHandshakeException);
6868
}
6969

7070
@Test

0 commit comments

Comments
 (0)