Allow withTlsSocketStrategyFactory to work without SSL bundle
Update `HttpComponentsHttpClientBuilder` so that `withTlsSocketStrategyFactory` is called even if there is no SSL bundle. See gh-43422
This commit is contained in:
@@ -119,7 +119,9 @@ public final class HttpComponentsHttpClientBuilder {
|
||||
* Return a new {@link HttpComponentsHttpClientBuilder} with a replacement
|
||||
* {@link TlsSocketStrategy} factory.
|
||||
* @param tlsSocketStrategyFactory the new factory used to create a
|
||||
* {@link TlsSocketStrategy} for a given {@link SslBundle}
|
||||
* {@link TlsSocketStrategy}. The function will be provided with a {@link SslBundle}
|
||||
* or {@code null} if no bundle is selected. Only non {@code null} results will be
|
||||
* applied.
|
||||
* @return a new {@link HttpComponentsHttpClientBuilder} instance
|
||||
*/
|
||||
public HttpComponentsHttpClientBuilder withTlsSocketStrategyFactory(
|
||||
@@ -166,9 +168,9 @@ public final class HttpComponentsHttpClientBuilder {
|
||||
private PoolingHttpClientConnectionManager createConnectionManager(HttpClientSettings settings) {
|
||||
PoolingHttpClientConnectionManagerBuilder builder = PoolingHttpClientConnectionManagerBuilder.create()
|
||||
.useSystemProperties();
|
||||
PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
builder.setDefaultSocketConfig(createSocketConfig(settings));
|
||||
map.from(settings::sslBundle).as(this.tlsSocketStrategyFactory).to(builder::setTlsSocketStrategy);
|
||||
map.from(settings::sslBundle).as(this.tlsSocketStrategyFactory).whenNonNull().to(builder::setTlsSocketStrategy);
|
||||
this.connectionManagerCustomizer.accept(builder);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ final class HttpComponentsSslBundleTlsStrategy {
|
||||
}
|
||||
|
||||
static DefaultClientTlsStrategy get(SslBundle sslBundle) {
|
||||
if (sslBundle == null) {
|
||||
return null;
|
||||
}
|
||||
SslOptions options = sslBundle.getOptions();
|
||||
SSLContext sslContext = sslBundle.createSslContext();
|
||||
return new DefaultClientTlsStrategy(sslContext, options.getEnabledProtocols(), options.getCiphers(), null,
|
||||
|
||||
Reference in New Issue
Block a user