|
|
|
@ -17,7 +17,6 @@
|
|
|
|
|
package org.springframework.boot.web.servlet.server;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
@ -126,6 +125,7 @@ import org.springframework.boot.web.servlet.ServletContextInitializer;
|
|
|
|
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
|
|
|
|
import org.springframework.boot.web.servlet.server.Session.SessionTrackingMode;
|
|
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
|
|
import org.springframework.core.io.FileSystemResource;
|
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
@ -543,7 +543,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
|
this.webServer.start();
|
|
|
|
|
KeyStore keyStore = KeyStore.getInstance("pkcs12");
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.p12")), "secret".toCharArray());
|
|
|
|
|
loadStore(keyStore, new FileSystemResource("src/test/resources/test.p12"));
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "secret".toCharArray()).build());
|
|
|
|
@ -561,7 +561,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
|
this.webServer.start();
|
|
|
|
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")), "secret".toCharArray());
|
|
|
|
|
loadStore(keyStore, new FileSystemResource("src/test/resources/test.jks"));
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
|
|
|
|
@ -594,7 +594,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
|
this.webServer.start();
|
|
|
|
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")), "secret".toCharArray());
|
|
|
|
|
loadStore(keyStore, new FileSystemResource("src/test/resources/test.jks"));
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
|
|
|
|
@ -632,7 +632,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
this.webServer = factory.getWebServer();
|
|
|
|
|
this.webServer.start();
|
|
|
|
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
|
|
|
|
keyStore.load(new FileInputStream(new File("src/test/resources/test.jks")), "secret".toCharArray());
|
|
|
|
|
loadStore(keyStore, new FileSystemResource("src/test/resources/test.jks"));
|
|
|
|
|
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
|
|
|
|
|
new SSLContextBuilder().loadTrustMaterial(null, new TrustSelfSignedStrategy())
|
|
|
|
|
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
|
|
|
|
@ -1357,9 +1357,14 @@ public abstract class AbstractServletWebServerFactoryTests {
|
|
|
|
|
private KeyStore loadStore() throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
|
|
|
|
|
KeyStore keyStore = KeyStore.getInstance("JKS");
|
|
|
|
|
Resource resource = new ClassPathResource("test.jks");
|
|
|
|
|
try (InputStream inputStream = resource.getInputStream()) {
|
|
|
|
|
keyStore.load(inputStream, "secret".toCharArray());
|
|
|
|
|
return keyStore;
|
|
|
|
|
loadStore(keyStore, resource);
|
|
|
|
|
return keyStore;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadStore(KeyStore keyStore, Resource resource)
|
|
|
|
|
throws IOException, NoSuchAlgorithmException, CertificateException {
|
|
|
|
|
try (InputStream stream = resource.getInputStream()) {
|
|
|
|
|
keyStore.load(stream, "secret".toCharArray());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|