-
Notifications
You must be signed in to change notification settings - Fork 923
Replace deprecated SSLConnectionSocketFactory with recommended API #6281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/master/apache5x
Are you sure you want to change the base?
Replace deprecated SSLConnectionSocketFactory with recommended API #6281
Conversation
724e1b2
to
034f7b6
Compare
|
@@ -452,12 +454,27 @@ public interface Builder extends SdkHttpClient.Builder<Apache5HttpClient.Builder | |||
Builder dnsResolver(DnsResolver dnsResolver); | |||
|
|||
/** | |||
* @deprecated this has been replaced with {{@link #tlsSocketStrategy(TlsSocketStrategy)}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explain that this is here to ease migration from 4.5.x?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -252,4 +258,76 @@ private HttpExecuteResponse makeRequestWithHttpClient(SdkHttpClient httpClient) | |||
return httpClient.prepareRequest(request).call(); | |||
} | |||
|
|||
@Test | |||
public void tls_strategy_configuration() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: can we fix the test names so they match our normal conventions? i.e. methodToTest_when_expectedBehavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.socketFactory(legacyFactorySpy) | ||
.tlsSocketStrategy(tlsStrategySpy) // This should override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just disallow setting both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
2bcd1e2
to
dcaaaf6
Compare
Motivation and Context
Apache HttpClient 5.x deprecated
ConnectionSocketFactory
in favor of the newTlsSocketStrategy
interface. This change updates the AWS SDK's Apache5 HTTP client to support the modern TLS configuration approach while maintaining backward compatibility with existing code.Historical Context: Earlier versions of this implementation incorrectly used
SSLConnectionSocketFactory
instead of the more generalConnectionSocketFactory
interface. The correct API should have beenConnectionSocketFactory
, which was consistent with the SDK's Apache4 client implementation. However, Apache HttpClient 5.x has since deprecatedConnectionSocketFactory
entirely as part of a broader architectural redesign to better separate concerns between socket creation and TLS upgrade operations.The new
TlsSocketStrategy
interface provides a cleaner abstraction specifically for TLS upgrade operations, moving away from the socket factory pattern that mixed plain socket creation with TLS layering concerns.Modifications
Added
tlsSocketStrategy()
method inApache5HttpClient.Builder
to support the modern TLS configuration approachConnectionSocketFactoryToTlsStrategyAdapter
class that adapts legacyConnectionSocketFactory
instances to work with the newTlsSocketStrategy
interfaceSdkSslSocket
wrapper for enhanced SSL socket logging and monitoringgetEffectiveTlsStrategy()
method to handle both legacy and modern configurationsModified
SdkTlsSocketFactory
now extendsDefaultClientTlsStrategy
instead ofSSLConnectionSocketFactory
setTlsSocketStrategy()
instead of deprecatedsetSSLSocketFactory()
SSLConnectionSocketFactory
toConnectionSocketFactory
and marked as deprecatedinitializeSocket()
instead ofprepareSocket()
Backward Compatibility
ConnectionSocketFactory
support retained: The deprecatedsocketFactory()
method has not been removed to maintain backward compatibility for existing use cases, including scenarios where customers configure plain HTTP connections usingPlainConnectionSocketFactory
for services that support both HTTP and HTTPS endpointstlsSocketStrategy()
takes precedence oversocketFactory()
Migration Path
Users should migrate from:
To:
Types of changes
License