Skip to content

Commit 6da16d7

Browse files
authored
Merge pull request #497 from yidongnan/fix/in-process-TLS-setup
Don't try to setup TLS security for in-process-server
2 parents 39e39b2 + 16df407 commit 6da16d7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/serverfactory/InProcessGrpcServerFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ protected InProcessServerBuilder newServerBuilder() {
8282
return InProcessServerBuilder.forName(this.name);
8383
}
8484

85+
@Override
86+
protected void configureSecurity(final InProcessServerBuilder builder) {
87+
// No need to configure security as we are in process only.
88+
// There is also no need to throw exceptions if transport security is configured.
89+
}
90+
8591
@Override
8692
public String getAddress() {
8793
return "in-process:" + this.name;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2016-2021 Michael Zhang <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
10+
* Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13+
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
15+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16+
*/
17+
18+
package net.devh.boot.grpc.test.setup;
19+
20+
import org.springframework.boot.test.context.SpringBootTest;
21+
import org.springframework.test.annotation.DirtiesContext;
22+
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
23+
24+
import lombok.extern.slf4j.Slf4j;
25+
import net.devh.boot.grpc.test.config.BaseAutoConfiguration;
26+
import net.devh.boot.grpc.test.config.ServiceConfiguration;
27+
28+
/**
29+
* A test checking that the server and client can start and connect to each other with minimal config.
30+
*
31+
* @author Daniel Theuke ([email protected])
32+
*/
33+
@Slf4j
34+
@SpringBootTest(properties = {
35+
"grpc.server.port=-1",
36+
"grpc.server.in-process-name=test",
37+
"grpc.server.security.enabled=true",
38+
"grpc.server.security.certificateChain=file:src/test/resources/certificates/server.crt",
39+
"grpc.server.security.privateKey=file:src/test/resources/certificates/server.key",
40+
"grpc.server.security.trustCertCollection=file:src/test/resources/certificates/trusted-clients-collection",
41+
"grpc.server.security.clientAuth=REQUIRE",
42+
43+
"grpc.client.test.address=in-process:test",
44+
"grpc.client.test.security.authorityOverride=localhost",
45+
"grpc.client.test.security.trustCertCollection=file:src/test/resources/certificates/trusted-servers-collection",
46+
"grpc.client.test.security.clientAuthEnabled=true",
47+
"grpc.client.test.security.certificateChain=file:src/test/resources/certificates/client1.crt",
48+
"grpc.client.test.security.privateKey=file:src/test/resources/certificates/client1.key"})
49+
@SpringJUnitConfig(classes = {ServiceConfiguration.class, BaseAutoConfiguration.class})
50+
@DirtiesContext
51+
public class SelfSignedInProcessSetupTest extends AbstractSimpleServerClientTest {
52+
53+
public SelfSignedInProcessSetupTest() {
54+
log.info("--- SelfSignedInProcessSetupTest ---");
55+
}
56+
57+
}

0 commit comments

Comments
 (0)