-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ssl bundles not working because of wrong condition (#3641)
* Add test for ssl bundle configuration * Fix support of ssl bundles --------- Co-authored-by: Dimitar Popov <[email protected]>
- Loading branch information
Showing
3 changed files
with
77 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...rc/test/java/org/springframework/cloud/gateway/test/ssl/ClientCertAuthSSLBundleTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.springframework.cloud.gateway.test.ssl; | ||
|
||
import io.netty.handler.ssl.SslContextBuilder; | ||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.ssl.SslBundles; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.http.client.reactive.ReactorClientHttpConnector; | ||
import org.springframework.test.annotation.DirtiesContext; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import reactor.netty.http.client.HttpClient; | ||
|
||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; | ||
|
||
@SpringBootTest(webEnvironment = RANDOM_PORT) | ||
@DirtiesContext | ||
@ActiveProfiles("client-auth-ssl-bundle") | ||
public class ClientCertAuthSSLBundleTests extends SingleCertSSLTests { | ||
@Autowired | ||
private SslBundles sslBundles; | ||
|
||
@BeforeEach | ||
public void setup() throws Exception { | ||
final var sslBundle = sslBundles.getBundle("scg-keystore-with-different-key-password"); | ||
final var sslContext = SslContextBuilder.forClient() | ||
.trustManager(InsecureTrustManagerFactory.INSTANCE) | ||
.keyManager(sslBundle.getManagers().getKeyManagerFactory()) | ||
.build(); | ||
HttpClient httpClient = HttpClient.create().secure(ssl -> ssl.sslContext(sslContext)); | ||
setup(new ReactorClientHttpConnector(httpClient), "https://localhost:" + port); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
spring-cloud-gateway-server/src/test/resources/application-client-auth-ssl-bundle.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
test: | ||
uri: lb:https://testservice | ||
|
||
server: | ||
ssl: | ||
enabled: true | ||
key-alias: scg | ||
key-store-password: scg1234 | ||
key-password: keyscg1234 | ||
key-store: classpath:scg-keystore-with-different-key-password.jks | ||
trust-store: classpath:scg-truststore.jks | ||
trust-store-password: scg1234 | ||
trust-store-type: JKS | ||
key-store-type: JKS | ||
client-auth: Need | ||
spring: | ||
cloud: | ||
gateway: | ||
httpclient: | ||
ssl: | ||
ssl-bundle: scg-keystore-with-different-key-password | ||
trustedX509Certificates: | ||
- src/test/resources/single-cert-for-different-key-password.pem | ||
default-filters: | ||
- PrefixPath=/httpbin | ||
routes: | ||
- id: default_path_to_httpbin | ||
uri: ${test.uri} | ||
order: 10000 | ||
predicates: | ||
- name: Path | ||
args: | ||
pattern: /** | ||
ssl: | ||
bundle: | ||
jks: | ||
scg-keystore-with-different-key-password: | ||
key: | ||
password: keyscg1234 | ||
keystore: | ||
type: JKS | ||
location: classpath:scg-keystore-with-different-key-password.jks | ||
password: scg1234 |