Revert "Upgrade to HttpClient5 5.3"

This reverts commit 31f3f31ac1.

See gh-39007
This commit is contained in:
Andy Wilkinson 2024-01-05 11:40:41 +00:00
parent 4b89723861
commit 28490738ae
4 changed files with 9 additions and 29 deletions

View File

@ -442,7 +442,7 @@ bom {
] ]
} }
} }
library("HttpClient5", "5.3") { library("HttpClient5", "5.2.3") {
group("org.apache.httpcomponents.client5") { group("org.apache.httpcomponents.client5") {
modules = [ modules = [
"httpclient5", "httpclient5",

View File

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

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,6 +64,7 @@ import org.apache.hc.client5.http.HttpHostConnectException;
import org.apache.hc.client5.http.classic.HttpClient; import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients; import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.NoHttpResponseException; import org.apache.hc.core5.http.NoHttpResponseException;
import org.apache.hc.core5.ssl.SSLContextBuilder; import org.apache.hc.core5.ssl.SSLContextBuilder;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -87,6 +87,7 @@ import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
import org.apache.hc.client5.http.protocol.HttpClientContext; import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.io.HttpClientResponseHandler; import org.apache.hc.core5.http.io.HttpClientResponseHandler;
import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http.protocol.HttpContext;
@ -1403,7 +1404,7 @@ public abstract class AbstractServletWebServerFactoryTests {
compression.setExcludedUserAgents(excludedUserAgents); compression.setExcludedUserAgents(excludedUserAgents);
} }
factory.setCompression(compression); factory.setCompression(compression);
factory.addInitializers(new ServletRegistrationBean<>(new HttpServlet() { factory.addInitializers(new ServletRegistrationBean<HttpServlet>(new HttpServlet() {
@Override @Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
@ -1630,7 +1631,7 @@ public abstract class AbstractServletWebServerFactoryTests {
} }
@Override @Override
public boolean isTrusted(X509Certificate[] chain, String authType) { public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
String hexSerialNumber = chain[0].getSerialNumber().toString(16); String hexSerialNumber = chain[0].getSerialNumber().toString(16);
boolean isMatch = hexSerialNumber.equalsIgnoreCase(this.serialNumber); boolean isMatch = hexSerialNumber.equalsIgnoreCase(this.serialNumber);
return super.isTrusted(chain, authType) && isMatch; return super.isTrusted(chain, authType) && isMatch;
@ -1774,16 +1775,4 @@ public abstract class AbstractServletWebServerFactoryTests {
} }
protected static class TrustSelfSignedStrategy implements TrustStrategy {
public TrustSelfSignedStrategy() {
}
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) {
return chain.length == 1;
}
}
} }