Skip to content

Commit 22db413

Browse files
committed
pr feedbacks
1 parent ac2e3f6 commit 22db413

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

runtime/protocol/http-client-engines/http-client-engine-crt/api/http-client-engine-crt.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ public final class aws/smithy/kotlin/runtime/http/engine/crt/CrtHttpEngineConfig
1818
public final fun getCaDir ()Ljava/lang/String;
1919
public final fun getCaFile ()Ljava/lang/String;
2020
public final fun getCaRoot ()Ljava/lang/String;
21-
public final fun getCipherPreference ()Laws/sdk/kotlin/crt/io/TlsCipherPreference;
2221
public final fun getClientBootstrap ()Laws/sdk/kotlin/crt/io/ClientBootstrap;
2322
public final fun getInitialWindowSizeBytes ()I
2423
public final fun getMaxConnections-pVg5ArA ()I
24+
public final fun getTlsCipherPreference ()Laws/sdk/kotlin/crt/io/TlsCipherPreference;
2525
public final fun getVerifyPeer ()Z
2626
public final fun setCaDir (Ljava/lang/String;)V
2727
public final fun setCaFile (Ljava/lang/String;)V
2828
public final fun setCaRoot (Ljava/lang/String;)V
29-
public final fun setCipherPreference (Laws/sdk/kotlin/crt/io/TlsCipherPreference;)V
3029
public final fun setClientBootstrap (Laws/sdk/kotlin/crt/io/ClientBootstrap;)V
30+
public final fun setTlsCipherPreference (Laws/sdk/kotlin/crt/io/TlsCipherPreference;)V
3131
public final fun setVerifyPeer (Z)V
3232
public fun toBuilderApplicator ()Lkotlin/jvm/functions/Function1;
3333
}
@@ -37,18 +37,18 @@ public final class aws/smithy/kotlin/runtime/http/engine/crt/CrtHttpEngineConfig
3737
public final fun getCaDir ()Ljava/lang/String;
3838
public final fun getCaFile ()Ljava/lang/String;
3939
public final fun getCaRoot ()Ljava/lang/String;
40-
public final fun getCipherPreference ()Laws/sdk/kotlin/crt/io/TlsCipherPreference;
4140
public final fun getClientBootstrap ()Laws/sdk/kotlin/crt/io/ClientBootstrap;
4241
public final fun getInitialWindowSizeBytes ()I
4342
public final fun getMaxConnections-pVg5ArA ()I
43+
public final fun getTlsCipherPreference ()Laws/sdk/kotlin/crt/io/TlsCipherPreference;
4444
public final fun getVerifyPeer ()Z
4545
public final fun setCaDir (Ljava/lang/String;)V
4646
public final fun setCaFile (Ljava/lang/String;)V
4747
public final fun setCaRoot (Ljava/lang/String;)V
48-
public final fun setCipherPreference (Laws/sdk/kotlin/crt/io/TlsCipherPreference;)V
4948
public final fun setClientBootstrap (Laws/sdk/kotlin/crt/io/ClientBootstrap;)V
5049
public final fun setInitialWindowSizeBytes (I)V
5150
public final fun setMaxConnections-WZ4Q5Ns (I)V
51+
public final fun setTlsCipherPreference (Laws/sdk/kotlin/crt/io/TlsCipherPreference;)V
5252
public final fun setVerifyPeer (Z)V
5353
}
5454

runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/ConnectionManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal class ConnectionManager(
3737
caRoot = config.caRoot
3838
caFile = config.caFile
3939
caDir = config.caDir
40-
tlsCipherPreference = config.cipherPreference
40+
tlsCipherPreference = config.tlsCipherPreference
4141
verifyPeer = config.verifyPeer
4242
}
4343
.build()

runtime/protocol/http-client-engines/http-client-engine-crt/jvm/src/aws/smithy/kotlin/runtime/http/engine/crt/CrtHttpEngineConfig.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,32 @@ public class CrtHttpEngineConfig private constructor(builder: Builder) : HttpCli
4646
public var clientBootstrap: ClientBootstrap? = builder.clientBootstrap
4747

4848
/**
49-
* Certificate Authority content in PEM format
50-
* Mutually exclusive with caFile and caDir.
49+
* Certificate authority content in PEM format
50+
* Mutually exclusive with [caFile] and [caDir].
5151
*/
5252
public var caRoot: String? = builder.caRoot
5353

5454
/**
5555
* Path to the root certificate. Must be in PEM format.
56-
* Mutually exclusive with caRoot.
56+
* Mutually exclusive with [caRoot]. Can be used independently or together with [caDir].
5757
*/
5858
public var caFile: String? = builder.caFile
5959

6060
/**
61-
* Path to the local trust store. Can be null.
62-
* Mutually exclusive with caRoot.
61+
* Path to the local trust store. Must be in PEM format.
62+
* Mutually exclusive with [caRoot]. Can be used independently or together with [caFile].
6363
*/
6464
public var caDir: String? = builder.caDir
6565

6666
/**
6767
* TLS cipher suite preference for connections.
6868
* Controls which cipher suites are available during TLS negotiation.
6969
*/
70-
public var cipherPreference: TlsCipherPreference = builder.cipherPreference
70+
public var tlsCipherPreference: TlsCipherPreference = builder.tlsCipherPreference
7171

7272
/**
7373
* Whether to verify the peer's certificate during TLS handshake.
74-
* When false, accepts any certificate (insecure, for testing only).
74+
* When false, accepts any certificate.
7575
*/
7676
public var verifyPeer: Boolean = builder.verifyPeer
7777

@@ -85,7 +85,7 @@ public class CrtHttpEngineConfig private constructor(builder: Builder) : HttpCli
8585
caRoot = this@CrtHttpEngineConfig.caRoot
8686
caFile = this@CrtHttpEngineConfig.caFile
8787
caDir = this@CrtHttpEngineConfig.caDir
88-
cipherPreference = this@CrtHttpEngineConfig.cipherPreference
88+
tlsCipherPreference = this@CrtHttpEngineConfig.tlsCipherPreference
8989
verifyPeer = this@CrtHttpEngineConfig.verifyPeer
9090
}
9191
}
@@ -132,7 +132,7 @@ public class CrtHttpEngineConfig private constructor(builder: Builder) : HttpCli
132132
* TLS cipher suite preference for connections.
133133
* Controls which cipher suites are available during TLS negotiation.
134134
*/
135-
public var cipherPreference: TlsCipherPreference = TlsCipherPreference.SYSTEM_DEFAULT
135+
public var tlsCipherPreference: TlsCipherPreference = TlsCipherPreference.SYSTEM_DEFAULT
136136

137137
/**
138138
* Whether to verify the peer's certificate during TLS handshake.

runtime/protocol/http-client-engines/http-client-engine-okhttp/jvm/src/aws/smithy/kotlin/runtime/http/engine/okhttp/OkHttpEngine.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,13 @@ private fun toOkHttpTlsVersion(sdkTlsVersion: SdkTlsVersion): OkHttpTlsVersion =
203203
/**
204204
* Creates an SSL context with custom trust and key managers
205205
*/
206-
private fun createSslContext(trustManagerProvider: TlsTrustManagersProvider?, keyManagerProvider: TlsKeyManagersProvider?): Pair<SSLContext, X509TrustManager> {
207-
val trustManagers = trustManagerProvider?.trustManagers()
208-
val keyManagers = keyManagerProvider?.keyManagers()
206+
private fun createSslContext(trustManagersProvider: TlsTrustManagersProvider?, keyManagersProvider: TlsKeyManagersProvider?): Pair<SSLContext, X509TrustManager> {
207+
val trustManagers = trustManagersProvider?.trustManagers()
208+
val keyManagers = keyManagersProvider?.keyManagers()
209209

210-
if (trustManagerProvider != null && (trustManagers.isNullOrEmpty() || trustManagers[0] !is X509TrustManager)) {
211-
throw IllegalStateException("Unexpected trust managers")
210+
if (trustManagersProvider != null) {
211+
check(!trustManagers.isNullOrEmpty()) { "Trust managers provider returned null or empty trust managers." }
212+
check(trustManagers[0] is X509TrustManager) { "Trust managers provider must return X509TrustManager." }
212213
}
213214

214215
val sslContext = SSLContext.getInstance("TLS")

0 commit comments

Comments
 (0)