Upgrade to HttpClient5 5.3

Closes gh-39007
This commit is contained in:
Andy Wilkinson
2024-01-04 16:32:24 +00:00
parent 65bbfdcfe8
commit 31f3f31ac1
4 changed files with 29 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ import java.net.URI;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashSet;
@@ -40,11 +41,11 @@ import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuil
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.ssl.SSLContextBuilder;
import org.apache.hc.core5.ssl.TrustStrategy;
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.web.client.RestTemplateBuilder;
@@ -993,7 +994,7 @@ public class TestRestTemplate {
ENABLE_REDIRECTS,
/**
* Use a {@link SSLConnectionSocketFactory} with {@link TrustSelfSignedStrategy}.
* Use a {@link SSLConnectionSocketFactory} that trusts self-signed certificates.
*/
SSL
@@ -1085,4 +1086,13 @@ public class TestRestTemplate {
}
private static class TrustSelfSignedStrategy implements TrustStrategy {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) {
return chain.length == 1;
}
}
}