-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34468 from cescoffier/cve-2023-2974
Enforce the configured TLS version
- Loading branch information
Showing
10 changed files
with
227 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
integration-tests/vertx-http/src/main/java/io/quarkus/it/vertx/HelloResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.quarkus.it.vertx; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
@Path("/hello") | ||
public class HelloResource { | ||
|
||
@GET | ||
public String hello() { | ||
return "hello"; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
integration-tests/vertx-http/src/test/java/io/quarkus/it/vertx/ServerWithTLS13Only.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.quarkus.it.vertx; | ||
|
||
import java.util.Map; | ||
|
||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
|
||
public class ServerWithTLS13Only implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of( | ||
"quarkus.http.ssl.protocols", "TLSv1.3"); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...tests/vertx-http/src/test/java/io/quarkus/it/vertx/TlsProtocolVersionDefaultTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package io.quarkus.it.vertx; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.CompletionException; | ||
|
||
import javax.net.ssl.SSLHandshakeException; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.vertx.core.net.JksOptions; | ||
import io.vertx.ext.web.client.WebClientOptions; | ||
import io.vertx.mutiny.core.Vertx; | ||
import io.vertx.mutiny.ext.web.client.WebClient; | ||
|
||
@QuarkusTest | ||
public class TlsProtocolVersionDefaultTestCase { | ||
|
||
@TestHTTPResource(value = "/hello", ssl = true) | ||
String url; | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@Test | ||
void testWithWebClientRequestingMultipleTlsVersions() { | ||
// The Web client is requesting TLS 1.2 or 1.3, the server is exposing 1.3 - all good | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
var resp = client.getAbs(url).sendAndAwait(); | ||
Assertions.assertEquals(200, resp.statusCode()); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls13() { | ||
// The Web client is requesting TLS 1.3, the server is exposing 1.3 - all good | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.3")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
var resp = client.getAbs(url).sendAndAwait(); | ||
Assertions.assertEquals(200, resp.statusCode()); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls12() { | ||
// The Web client is requesting TLS 1.2, the server is exposing 1.2 and 1.3 - all good | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.2")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
var resp = client.getAbs(url).sendAndAwait(); | ||
Assertions.assertEquals(200, resp.statusCode()); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls11() { | ||
// The Web client is requesting TLS 1.1, the server is exposing 1.2 and 1.3 - KO | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.1")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
Throwable exception = Assertions.assertThrows(CompletionException.class, () -> client.getAbs(url).sendAndAwait()); | ||
Assertions.assertTrue(exception.getCause() instanceof SSLHandshakeException); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...sts/vertx-http/src/test/java/io/quarkus/it/vertx/TlsProtocolVersionSelectionTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package io.quarkus.it.vertx; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.CompletionException; | ||
|
||
import javax.net.ssl.SSLHandshakeException; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
import io.vertx.core.net.JksOptions; | ||
import io.vertx.ext.web.client.WebClientOptions; | ||
import io.vertx.mutiny.core.Vertx; | ||
import io.vertx.mutiny.ext.web.client.WebClient; | ||
|
||
@QuarkusTest | ||
@TestProfile(ServerWithTLS13Only.class) | ||
public class TlsProtocolVersionSelectionTestCase { | ||
|
||
@TestHTTPResource(value = "/hello", ssl = true) | ||
String url; | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@Test | ||
void testWithWebClientRequestingMultipleTlsVersions() { | ||
// The Web client is requesting TLS 1.2 or 1.3, the server is exposing 1.3 - all good | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
var resp = client.getAbs(url).sendAndAwait(); | ||
Assertions.assertEquals(200, resp.statusCode()); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls13() { | ||
// The Web client is requesting TLS 1.3, the server is exposing 1.3 - all good | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.3")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
var resp = client.getAbs(url).sendAndAwait(); | ||
Assertions.assertEquals(200, resp.statusCode()); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls12() { | ||
// The Web client is requesting TLS 1.2, the server is exposing 1.3 - KO | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.2")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
Throwable exception = Assertions.assertThrows(CompletionException.class, () -> client.getAbs(url).sendAndAwait()); | ||
Assertions.assertTrue(exception.getCause() instanceof SSLHandshakeException); | ||
} | ||
|
||
@Test | ||
void testWithWebClientRequestingTls11() { | ||
// The Web client is requesting TLS 1.1, the server is exposing 1.3 - KO | ||
WebClient client = WebClient.create(vertx, new WebClientOptions().setSsl(true) | ||
.setEnabledSecureTransportProtocols(Set.of("TLSv1.1")) | ||
.setKeyStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-keystore-1.jks").setPassword("password")) | ||
.setTrustStoreOptions( | ||
new JksOptions().setPath("src/test/resources/client-truststore.jks").setPassword("password")) | ||
.setVerifyHost(false)); | ||
Throwable exception = Assertions.assertThrows(CompletionException.class, () -> client.getAbs(url).sendAndAwait()); | ||
Assertions.assertTrue(exception.getCause() instanceof SSLHandshakeException); | ||
} | ||
} |