Skip to content

Commit 7990c8b

Browse files
committed
Merge branch '1.5.x' into 2.0.x
2 parents 28b38dd + 946e826 commit 7990c8b

File tree

5 files changed

+61
-11
lines changed

5 files changed

+61
-11
lines changed

spring-boot-project/spring-boot-dependencies/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<jedis.version>2.9.3</jedis.version>
100100
<jersey.version>2.26</jersey.version>
101101
<jest.version>5.3.4</jest.version>
102-
<jetty.version>9.4.14.v20181114</jetty.version>
102+
<jetty.version>9.4.15.v20190215</jetty.version>
103103
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
104104
<jetty-el.version>8.5.35.1</jetty-el.version>
105105
<jmustache.version>1.14</jmustache.version>

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,12 +21,16 @@
2121
import java.net.InetSocketAddress;
2222
import java.nio.charset.StandardCharsets;
2323
import java.security.KeyStore;
24+
import java.security.PrivateKey;
25+
import java.security.cert.X509Certificate;
2426
import java.time.Duration;
2527
import java.util.Arrays;
2628
import java.util.function.Consumer;
2729

30+
import javax.net.ssl.KeyManager;
2831
import javax.net.ssl.KeyManagerFactory;
2932
import javax.net.ssl.SSLException;
33+
import javax.net.ssl.X509KeyManager;
3034

3135
import io.netty.channel.ChannelHandlerContext;
3236
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -169,10 +173,22 @@ protected ReactorClientHttpConnector buildTrustAllSslWithClientKeyConnector()
169173
KeyManagerFactory clientKeyManagerFactory = KeyManagerFactory
170174
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
171175
clientKeyManagerFactory.init(clientKeyStore, "password".toCharArray());
172-
return new ReactorClientHttpConnector((options) -> options.sslSupport(
173-
(sslContextBuilder) -> sslContextBuilder.sslProvider(SslProvider.JDK)
174-
.trustManager(InsecureTrustManagerFactory.INSTANCE)
175-
.keyManager(clientKeyManagerFactory)));
176+
for (KeyManager keyManager : clientKeyManagerFactory.getKeyManagers()) {
177+
if (keyManager instanceof X509KeyManager) {
178+
X509KeyManager x509KeyManager = (X509KeyManager) keyManager;
179+
PrivateKey privateKey = x509KeyManager.getPrivateKey("spring-boot");
180+
if (privateKey != null) {
181+
X509Certificate[] certificateChain = x509KeyManager
182+
.getCertificateChain("spring-boot");
183+
return new ReactorClientHttpConnector((options) -> options
184+
.sslSupport((sslContextBuilder) -> sslContextBuilder
185+
.sslProvider(SslProvider.JDK)
186+
.trustManager(InsecureTrustManagerFactory.INSTANCE)
187+
.keyManager(privateKey, certificateChain)));
188+
}
189+
}
190+
}
191+
throw new IllegalStateException("Key with alias 'spring-boot' not found");
176192
}
177193

178194
protected void testClientAuthSuccess(Ssl sslConfiguration,

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java

+39-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.net.InetSocketAddress;
2626
import java.net.MalformedURLException;
2727
import java.net.ServerSocket;
28+
import java.net.Socket;
2829
import java.net.URI;
2930
import java.net.URISyntaxException;
3031
import java.net.URL;
@@ -74,6 +75,8 @@
7475
import org.apache.http.impl.client.HttpClientBuilder;
7576
import org.apache.http.impl.client.HttpClients;
7677
import org.apache.http.protocol.HttpContext;
78+
import org.apache.http.ssl.PrivateKeyDetails;
79+
import org.apache.http.ssl.PrivateKeyStrategy;
7780
import org.apache.http.ssl.SSLContextBuilder;
7881
import org.apache.http.ssl.TrustStrategy;
7982
import org.apache.jasper.EmbeddedServletOptions;
@@ -424,7 +427,7 @@ public void sslKeyAlias() throws Exception {
424427
this.webServer = factory.getWebServer(registration);
425428
this.webServer.start();
426429
TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy(
427-
"77e7c302");
430+
"5c7ae101");
428431
SSLContext sslContext = new SSLContextBuilder()
429432
.loadTrustMaterial(null, trustStrategy).build();
430433
HttpClient httpClient = HttpClients.custom()
@@ -500,7 +503,18 @@ public void pkcs12KeyStoreAndTrustStore() throws Exception {
500503
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
501504
new SSLContextBuilder()
502505
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
503-
.loadKeyMaterial(keyStore, "secret".toCharArray()).build());
506+
.loadKeyMaterial(keyStore, "secret".toCharArray(),
507+
new PrivateKeyStrategy() {
508+
509+
@Override
510+
public String chooseAlias(
511+
Map<String, PrivateKeyDetails> aliases,
512+
Socket socket) {
513+
return "spring-boot";
514+
}
515+
516+
})
517+
.build());
504518
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
505519
.build();
506520
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
@@ -524,7 +538,17 @@ public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
524538
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
525539
new SSLContextBuilder()
526540
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
527-
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
541+
.loadKeyMaterial(keyStore, "password".toCharArray(),
542+
new PrivateKeyStrategy() {
543+
544+
@Override
545+
public String chooseAlias(
546+
Map<String, PrivateKeyDetails> aliases,
547+
Socket socket) {
548+
return "spring-boot";
549+
}
550+
})
551+
.build());
528552
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
529553
.build();
530554
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
@@ -613,7 +637,17 @@ public void sslWithCustomSslStoreProvider() throws Exception {
613637
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
614638
new SSLContextBuilder()
615639
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
616-
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
640+
.loadKeyMaterial(keyStore, "password".toCharArray(),
641+
new PrivateKeyStrategy() {
642+
643+
@Override
644+
public String chooseAlias(
645+
Map<String, PrivateKeyDetails> aliases,
646+
Socket socket) {
647+
return "spring-boot";
648+
}
649+
})
650+
.build());
617651
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
618652
.build();
619653
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)