File tree Expand file tree Collapse file tree 3 files changed +77
-4
lines changed
spring-cloud-gateway-server/src
main/java/org/springframework/cloud/gateway/config
java/org/springframework/cloud/gateway/test/ssl Expand file tree Collapse file tree 3 files changed +77
-4
lines changed Original file line number Diff line number Diff line change @@ -67,10 +67,7 @@ protected HttpClientProperties.Ssl getSslProperties() {
67
67
}
68
68
69
69
protected SslBundle getBundle () {
70
- if (ssl .getSslBundle () == null || ssl .getSslBundle ().length () > 0 ) {
71
- return null ;
72
- }
73
- if (bundles .getBundleNames ().contains (ssl .getSslBundle ())) {
70
+ if (ssl .getSslBundle () != null && ssl .getSslBundle ().length () > 0 && bundles .getBundleNames ().contains (ssl .getSslBundle ())) {
74
71
return bundles .getBundle (ssl .getSslBundle ());
75
72
}
76
73
return null ;
Original file line number Diff line number Diff line change
1
+ package org .springframework .cloud .gateway .test .ssl ;
2
+
3
+ import io .netty .handler .ssl .SslContextBuilder ;
4
+ import io .netty .handler .ssl .util .InsecureTrustManagerFactory ;
5
+ import org .junit .jupiter .api .BeforeEach ;
6
+ import org .springframework .beans .factory .annotation .Autowired ;
7
+ import org .springframework .boot .ssl .SslBundles ;
8
+ import org .springframework .boot .test .context .SpringBootTest ;
9
+ import org .springframework .http .client .reactive .ReactorClientHttpConnector ;
10
+ import org .springframework .test .annotation .DirtiesContext ;
11
+ import org .springframework .test .context .ActiveProfiles ;
12
+ import reactor .netty .http .client .HttpClient ;
13
+
14
+ import static org .springframework .boot .test .context .SpringBootTest .WebEnvironment .RANDOM_PORT ;
15
+
16
+ @ SpringBootTest (webEnvironment = RANDOM_PORT )
17
+ @ DirtiesContext
18
+ @ ActiveProfiles ("client-auth-ssl-bundle" )
19
+ public class ClientCertAuthSSLBundleTests extends SingleCertSSLTests {
20
+ @ Autowired
21
+ private SslBundles sslBundles ;
22
+
23
+ @ BeforeEach
24
+ public void setup () throws Exception {
25
+ final var sslBundle = sslBundles .getBundle ("scg-keystore-with-different-key-password" );
26
+ final var sslContext = SslContextBuilder .forClient ()
27
+ .trustManager (InsecureTrustManagerFactory .INSTANCE )
28
+ .keyManager (sslBundle .getManagers ().getKeyManagerFactory ())
29
+ .build ();
30
+ HttpClient httpClient = HttpClient .create ().secure (ssl -> ssl .sslContext (sslContext ));
31
+ setup (new ReactorClientHttpConnector (httpClient ), "https://localhost:" + port );
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ test :
2
+ uri : lb:https://testservice
3
+
4
+ server :
5
+ ssl :
6
+ enabled : true
7
+ key-alias : scg
8
+ key-store-password : scg1234
9
+ key-password : keyscg1234
10
+ key-store : classpath:scg-keystore-with-different-key-password.jks
11
+ trust-store : classpath:scg-truststore.jks
12
+ trust-store-password : scg1234
13
+ trust-store-type : JKS
14
+ key-store-type : JKS
15
+ client-auth : Need
16
+ spring :
17
+ cloud :
18
+ gateway :
19
+ httpclient :
20
+ ssl :
21
+ ssl-bundle : scg-keystore-with-different-key-password
22
+ trustedX509Certificates :
23
+ - src/test/resources/single-cert-for-different-key-password.pem
24
+ default-filters :
25
+ - PrefixPath=/httpbin
26
+ routes :
27
+ - id : default_path_to_httpbin
28
+ uri : ${test.uri}
29
+ order : 10000
30
+ predicates :
31
+ - name : Path
32
+ args :
33
+ pattern : /**
34
+ ssl :
35
+ bundle :
36
+ jks :
37
+ scg-keystore-with-different-key-password :
38
+ key :
39
+ password : keyscg1234
40
+ keystore :
41
+ type : JKS
42
+ location : classpath:scg-keystore-with-different-key-password.jks
43
+ password : scg1234
You can’t perform that action at this time.
0 commit comments