|
|
|
@ -25,7 +25,6 @@ import java.io.PrintWriter;
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.ServerSocket;
|
|
|
|
|
import java.net.Socket;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
@ -75,8 +74,6 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
|
|
|
|
|
import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
|
|
import org.apache.http.impl.client.HttpClients;
|
|
|
|
|
import org.apache.http.protocol.HttpContext;
|
|
|
|
|
import org.apache.http.ssl.PrivateKeyDetails;
|
|
|
|
|
import org.apache.http.ssl.PrivateKeyStrategy;
|
|
|
|
|
import org.apache.http.ssl.SSLContextBuilder;
|
|
|
|
|
import org.apache.http.ssl.TrustStrategy;
|
|
|
|
|
import org.apache.jasper.EmbeddedServletOptions;
|
|
|
|
@ -402,7 +399,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
new ExampleServlet(true, false), "/hello");
|
|
|
|
|
this.webServer = factory.getWebServer(registration);
|
|
|
|
|
this.webServer.start();
|
|
|
|
|
TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy("5c7ae101");
|
|
|
|
|
TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy("3a3aaec8");
|
|
|
|
|
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, trustStrategy).build();
|
|
|
|
|
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext))
|
|
|
|
|
.build();
|
|
|
|
@ -464,14 +461,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.p12")), "secret".toCharArray());
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "secret".toCharArray(), new PrivateKeyStrategy() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String chooseAlias(Map<String, PrivateKeyDetails> aliases, Socket socket) {
|
|
|
|
|
return "spring-boot";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).build());
|
|
|
|
|
.loadKeyMaterial(keyStore, "secret".toCharArray()).build());
|
|
|
|
|
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
|
|
|
|
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
|
|
|
|
assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory)).isEqualTo("test");
|
|
|
|
@ -488,13 +478,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")), "secret".toCharArray());
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray(), new PrivateKeyStrategy() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String chooseAlias(Map<String, PrivateKeyDetails> aliases, Socket socket) {
|
|
|
|
|
return "spring-boot";
|
|
|
|
|
}
|
|
|
|
|
}).build());
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
|
|
|
|
|
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
|
|
|
|
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
|
|
|
|
assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory)).isEqualTo("test");
|
|
|
|
@ -565,13 +549,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")), "secret".toCharArray());
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray(), new PrivateKeyStrategy() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String chooseAlias(Map<String, PrivateKeyDetails> aliases, Socket socket) {
|
|
|
|
|
return "spring-boot";
|
|
|
|
|
}
|
|
|
|
|
}).build());
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
|
|
|
|
|
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
|
|
|
|
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
|
|
|
|
|
assertThat(getResponse(getLocalUrl("https", "/test.txt"), requestFactory)).isEqualTo("test");
|
|
|
|
|