Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6615e11

Browse files
Merge branch '2.1.x'
2 parents c2b35e1 + 4e73466 commit 6615e11

File tree

5 files changed

+61
-12
lines changed

5 files changed

+61
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<jedis.version>3.0.1</jedis.version>
120120
<jersey.version>2.28</jersey.version>
121121
<jest.version>6.3.1</jest.version>
122-
<jetty.version>9.4.14.v20181114</jetty.version>
122+
<jetty.version>9.4.15.v20190215</jetty.version>
123123
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
124124
<jetty-el.version>8.5.35.1</jetty-el.version>
125125
<jetty-reactive-httpclient.version>1.0.3</jetty-reactive-httpclient.version>

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@
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

29+
import javax.net.ssl.KeyManager;
2730
import javax.net.ssl.KeyManagerFactory;
2831
import javax.net.ssl.SSLException;
32+
import javax.net.ssl.X509KeyManager;
2933

3034
import io.netty.channel.ChannelHandlerContext;
3135
import io.netty.channel.ChannelInboundHandlerAdapter;
@@ -171,13 +175,24 @@ protected ReactorClientHttpConnector buildTrustAllSslWithClientKeyConnector()
171175
KeyManagerFactory clientKeyManagerFactory = KeyManagerFactory
172176
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
173177
clientKeyManagerFactory.init(clientKeyStore, "password".toCharArray());
174-
SslContextBuilder builder = SslContextBuilder.forClient()
175-
.sslProvider(SslProvider.JDK)
176-
.trustManager(InsecureTrustManagerFactory.INSTANCE)
177-
.keyManager(clientKeyManagerFactory);
178-
HttpClient client = HttpClient.create().wiretap(true)
179-
.secure((sslContextSpec) -> sslContextSpec.sslContext(builder));
180-
return new ReactorClientHttpConnector(client);
178+
for (KeyManager keyManager : clientKeyManagerFactory.getKeyManagers()) {
179+
if (keyManager instanceof X509KeyManager) {
180+
X509KeyManager x509KeyManager = (X509KeyManager) keyManager;
181+
PrivateKey privateKey = x509KeyManager.getPrivateKey("spring-boot");
182+
if (privateKey != null) {
183+
X509Certificate[] certificateChain = x509KeyManager
184+
.getCertificateChain("spring-boot");
185+
SslContextBuilder builder = SslContextBuilder.forClient()
186+
.sslProvider(SslProvider.JDK)
187+
.trustManager(InsecureTrustManagerFactory.INSTANCE)
188+
.keyManager(privateKey, certificateChain);
189+
HttpClient client = HttpClient.create().wiretap(true).secure(
190+
(sslContextSpec) -> sslContextSpec.sslContext(builder));
191+
return new ReactorClientHttpConnector(client);
192+
}
193+
}
194+
}
195+
throw new IllegalStateException("Key with alias 'spring-boot' not found");
181196
}
182197

183198
protected void testClientAuthSuccess(Ssl sslConfiguration,

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

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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;
@@ -423,7 +426,7 @@ public void sslKeyAlias() throws Exception {
423426
this.webServer = factory.getWebServer(registration);
424427
this.webServer.start();
425428
TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy(
426-
"3a3aaec8");
429+
"5c7ae101");
427430
SSLContext sslContext = new SSLContextBuilder()
428431
.loadTrustMaterial(null, trustStrategy).build();
429432
HttpClient httpClient = HttpClients.custom()
@@ -499,7 +502,18 @@ public void pkcs12KeyStoreAndTrustStore() throws Exception {
499502
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
500503
new SSLContextBuilder()
501504
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
502-
.loadKeyMaterial(keyStore, "secret".toCharArray()).build());
505+
.loadKeyMaterial(keyStore, "secret".toCharArray(),
506+
new PrivateKeyStrategy() {
507+
508+
@Override
509+
public String chooseAlias(
510+
Map<String, PrivateKeyDetails> aliases,
511+
Socket socket) {
512+
return "spring-boot";
513+
}
514+
515+
})
516+
.build());
503517
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
504518
.build();
505519
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
@@ -523,7 +537,17 @@ public void sslNeedsClientAuthenticationSucceedsWithClientCertificate()
523537
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
524538
new SSLContextBuilder()
525539
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
526-
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
540+
.loadKeyMaterial(keyStore, "password".toCharArray(),
541+
new PrivateKeyStrategy() {
542+
543+
@Override
544+
public String chooseAlias(
545+
Map<String, PrivateKeyDetails> aliases,
546+
Socket socket) {
547+
return "spring-boot";
548+
}
549+
})
550+
.build());
527551
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
528552
.build();
529553
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
@@ -614,7 +638,17 @@ public void sslWithCustomSslStoreProvider() throws Exception {
614638
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(
615639
new SSLContextBuilder()
616640
.loadTrustMaterial(null, new TrustSelfSignedStrategy())
617-
.loadKeyMaterial(keyStore, "password".toCharArray()).build());
641+
.loadKeyMaterial(keyStore, "password".toCharArray(),
642+
new PrivateKeyStrategy() {
643+
644+
@Override
645+
public String chooseAlias(
646+
Map<String, PrivateKeyDetails> aliases,
647+
Socket socket) {
648+
return "spring-boot";
649+
}
650+
})
651+
.build());
618652
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory)
619653
.build();
620654
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(
4.13 KB
Binary file not shown.
2.89 KB
Binary file not shown.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /