Skip to content

Commit 5ee5d1d

Browse files
Implement opt-out for PQ TLS (#6870)
* Implement opt-out for PQ TLS Java CRT 0.39.3 enables and prefers PQ by default, so `TLS_CIPHER_SYSTEM_DEFAULT` now uses PQ cipher suites. The `postQuantumTlsEnabled` builder option in aws-sdk-java-v2 now becomes an opt-out mechanism; setting it to false explicitly disables PQ by using policy `TLS_CIPHER_PREF_TLSv1_0_2023`. * Update release changelog * Only use opt-out policy if supported * Update CRT to 0.43.1 * Add pq-tls-test confirming everything works * Revert "Add pq-tls-test confirming everything works" This reverts commit 6871bd9. * Update javadoc * Use TLS_CIPHER_NON_PQ_DEFAULT cipher preference * Update .changes/next-release/bugfix-AWSSDKforJavav2-4b5fea2.json Co-authored-by: Zoe Wang <33073555+zoewangg@users.noreply.github.com> * Update .changes/next-release/bugfix-AWSSDKforJavav2-4b5fea2.json Co-authored-by: Zoe Wang <33073555+zoewangg@users.noreply.github.com> * Add warn log statement if PQ disabled but non-PQ default not supported * Fix checkstyle error * Update changelog entry --------- Co-authored-by: Will Childs-Klein <childw@amazon.com> Co-authored-by: Will Childs-Klein <willck93@gmail.com>
1 parent f74c501 commit 5ee5d1d

File tree

6 files changed

+37
-36
lines changed

6 files changed

+37
-36
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "AWS CRT HTTP Client",
4+
"contributor": "WillChilds-Klein",
5+
"description": "Java CRT 0.39.3 enables and prefers Post Quantum TLS (PQ TLS) by default when supported by the platform and service. The `postQuantumTlsEnabled` builder option in aws-sdk-java-v2 now becomes an opt-out mechanism; setting it to false explicitly disables PQ TLS."
6+
}

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/AwsCrtAsyncHttpClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ AwsCrtAsyncHttpClient.Builder tcpKeepAliveConfiguration(Consumer<TcpKeepAliveCon
239239
* not supported on the platform, the SDK will use the default TLS cipher suites.
240240
*
241241
* <p>
242-
* See <a href="https://docs.aws.amazon.com/kms/latest/developerguide/pqtls.html">Using hybrid post-quantum TLS with AWS KMS</a>
242+
* See <a href="https://docs.aws.amazon.com/kms/latest/developerguide/pqtls.html">Using hybrid post-quantum
243+
* TLS with AWS KMS</a>
243244
*
244245
* <p>
245-
* It's disabled by default.
246+
* It's enabled by default. If set to {@code false}, the SDK will use the latest recommended non-post-quantum
247+
* TLS cipher policy, which may change over time as the underlying CRT library is updated.
246248
*
247249
* @param postQuantumTlsEnabled whether to prefer Post Quantum TLS
248250
* @return The builder of the method chaining.

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/AwsCrtHttpClient.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,17 @@ AwsCrtHttpClient.Builder tcpKeepAliveConfiguration(Consumer<TcpKeepAliveConfigur
269269
tcpKeepAliveConfigurationBuilder);
270270

271271
/**
272-
* Configure whether to enable a hybrid post-quantum key exchange option for the Transport Layer Security (TLS) network
273-
* encryption protocol when communicating with services that support Post Quantum TLS. If Post Quantum cipher suites are
274-
* not supported on the platform, the SDK will use the default TLS cipher suites.
272+
* Configure whether to enable a hybrid post-quantum key exchange option for the Transport Layer Security (TLS)
273+
* network encryption protocol when communicating with services that support Post Quantum TLS. If Post Quantum
274+
* cipher suites are not supported on the platform, the SDK will use the default TLS cipher suites.
275275
*
276276
* <p>
277-
* See <a href="https://docs.aws.amazon.com/kms/latest/developerguide/pqtls.html">Using hybrid post-quantum TLS with AWS KMS</a>
277+
* See <a href="https://docs.aws.amazon.com/kms/latest/developerguide/pqtls.html">Using hybrid post-quantum
278+
* TLS with AWS KMS</a>
278279
*
279280
* <p>
280-
* It's disabled by default.
281+
* It's enabled by default. If set to {@code false}, the SDK will use the latest recommended non-post-quantum
282+
* TLS cipher policy, which may change over time as the underlying CRT library is updated.
281283
*
282284
* @param postQuantumTlsEnabled whether to prefer Post Quantum TLS
283285
* @return The builder of the method chaining.

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/internal/AwsCrtConfigurationUtils.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
import software.amazon.awssdk.annotations.SdkInternalApi;
2121
import software.amazon.awssdk.crt.io.SocketOptions;
2222
import software.amazon.awssdk.crt.io.TlsCipherPreference;
23-
import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient;
2423
import software.amazon.awssdk.http.crt.TcpKeepAliveConfiguration;
2524
import software.amazon.awssdk.utils.Logger;
2625
import software.amazon.awssdk.utils.NumericUtils;
2726

2827
@SdkInternalApi
2928
public final class AwsCrtConfigurationUtils {
30-
private static final Logger log = Logger.loggerFor(AwsCrtAsyncHttpClient.class);
29+
private static final Logger log = Logger.loggerFor(AwsCrtConfigurationUtils.class);
3130

3231
private AwsCrtConfigurationUtils() {
3332
}
@@ -55,19 +54,16 @@ public static SocketOptions buildSocketOptions(TcpKeepAliveConfiguration tcpKeep
5554
}
5655

5756
public static TlsCipherPreference resolveCipherPreference(Boolean postQuantumTlsEnabled) {
58-
TlsCipherPreference defaultTls = TlsCipherPreference.TLS_CIPHER_SYSTEM_DEFAULT;
59-
if (postQuantumTlsEnabled == null || !postQuantumTlsEnabled) {
60-
return defaultTls;
61-
}
62-
63-
TlsCipherPreference pqTls = TlsCipherPreference.TLS_CIPHER_PQ_DEFAULT;
64-
if (!pqTls.isSupported()) {
65-
log.warn(() -> "Hybrid post-quantum cipher suites are not supported on this platform. The SDK will use the system "
66-
+ "default cipher suites instead");
67-
return defaultTls;
57+
// As of v0.39.3, aws-crt-java prefers PQ by default, so only return the non-PQ-default policy
58+
// below if the caller explicitly disables PQ by passing in false.
59+
if (Boolean.FALSE.equals(postQuantumTlsEnabled)) {
60+
if (TlsCipherPreference.TLS_CIPHER_NON_PQ_DEFAULT.isSupported()) {
61+
return TlsCipherPreference.TLS_CIPHER_NON_PQ_DEFAULT;
62+
}
63+
log.warn(() -> "Post-quantum TLS was explicitly disabled but TLS_CIPHER_NON_PQ_DEFAULT is not supported. "
64+
+ "Falling back to TLS_CIPHER_SYSTEM_DEFAULT.");
6865
}
69-
70-
return pqTls;
66+
return TlsCipherPreference.TLS_CIPHER_SYSTEM_DEFAULT;
7167
}
7268

7369
}

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/internal/AwsCrtConfigurationUtilsTest.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
package software.amazon.awssdk.http.crt.internal;
1717

1818
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
19-
import static software.amazon.awssdk.crt.io.TlsCipherPreference.TLS_CIPHER_PQ_DEFAULT;
19+
import static software.amazon.awssdk.crt.io.TlsCipherPreference.TLS_CIPHER_NON_PQ_DEFAULT;
2020
import static software.amazon.awssdk.crt.io.TlsCipherPreference.TLS_CIPHER_SYSTEM_DEFAULT;
2121

2222
import java.time.Duration;
2323
import java.util.stream.Stream;
24-
import org.junit.jupiter.api.Assumptions;
25-
import org.junit.jupiter.api.Test;
2624
import org.junit.jupiter.params.ParameterizedTest;
2725
import org.junit.jupiter.params.provider.Arguments;
2826
import org.junit.jupiter.params.provider.MethodSource;
@@ -36,22 +34,19 @@
3634
class AwsCrtConfigurationUtilsTest {
3735
@ParameterizedTest
3836
@MethodSource("cipherPreferences")
39-
void resolveCipherPreference_pqNotSupported_shouldFallbackToSystemDefault(Boolean preferPqTls,
40-
TlsCipherPreference tlsCipherPreference) {
41-
Assumptions.assumeFalse(TLS_CIPHER_PQ_DEFAULT.isSupported());
42-
assertThat(AwsCrtConfigurationUtils.resolveCipherPreference(preferPqTls)).isEqualTo(tlsCipherPreference);
43-
}
44-
45-
@Test
46-
void resolveCipherPreference_pqSupported_shouldHonor() {
47-
Assumptions.assumeTrue(TLS_CIPHER_PQ_DEFAULT.isSupported());
48-
assertThat(AwsCrtConfigurationUtils.resolveCipherPreference(true)).isEqualTo(TLS_CIPHER_PQ_DEFAULT);
37+
void resolveCipherPreference_shouldResolveCorrectly(Boolean postQuantumTlsEnabled,
38+
TlsCipherPreference expectedPreference) {
39+
assertThat(AwsCrtConfigurationUtils.resolveCipherPreference(postQuantumTlsEnabled)).isEqualTo(expectedPreference);
4940
}
5041

5142
private static Stream<Arguments> cipherPreferences() {
43+
// On platforms where NON_PQ_DEFAULT is not supported (e.g. macOS), the code falls back to SYSTEM_DEFAULT.
44+
TlsCipherPreference expectedForFalse = TLS_CIPHER_NON_PQ_DEFAULT.isSupported()
45+
? TLS_CIPHER_NON_PQ_DEFAULT
46+
: TLS_CIPHER_SYSTEM_DEFAULT;
5247
return Stream.of(
5348
Arguments.of(null, TLS_CIPHER_SYSTEM_DEFAULT),
54-
Arguments.of(false, TLS_CIPHER_SYSTEM_DEFAULT),
49+
Arguments.of(false, expectedForFalse),
5550
Arguments.of(true, TLS_CIPHER_SYSTEM_DEFAULT)
5651
);
5752
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<rxjava3.version>3.1.5</rxjava3.version>
131131
<commons-codec.verion>1.17.1</commons-codec.verion>
132132
<jmh.version>1.37</jmh.version>
133-
<awscrt.version>0.43.9</awscrt.version>
133+
<awscrt.version>0.44.0</awscrt.version>
134134

135135
<!--Test dependencies -->
136136
<junit5.version>5.10.3</junit5.version>

0 commit comments

Comments
 (0)