Skip to content

Commit 603145d

Browse files
committed
first cut at rest tls
1 parent f63e00f commit 603145d

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

rest/tls/config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
configurationset:
2+
- configuration:
3+
name: selfsign
4+
ca: STEPZEN_SERVER_CRT
5+
- configuration:
6+
name: selfsignedmtls
7+
ca: STEPZEN_SERVER_CRT
8+
cert: STEPZEN_CLIENT_CRT
9+
key: STEPZEN_CLIENT_KEY

rest/tls/index.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
schema @sdl(files: ["tls.graphql"]) {
2+
query: Query
3+
}
4+

rest/tls/operations.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
query run {
2+
rest_self
3+
rest_self_mtls
4+
}

rest/tls/stepzen.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"endpoint": "api/miscellaneous"
3+
}

rest/tls/tests/Makefile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Makefile to build and validate a pair of *example* self-signed certificates for *simple* tests
2+
3+
# enable to debug ssl server
4+
# DEBUG:=-debug
5+
all: client.crt server.crt env
6+
7+
# server.crt client.key server.key
8+
client.crt:
9+
openssl req -x509 -newkey rsa:4096 -keyout client.key -out client.crt -sha256 -days 7650 \
10+
-subj "/C=US/ST=Florida/L=Jacksonville/O=LOCALCLIENT/OU=Com/CN=localhost" -nodes \
11+
-addext "subjectAltName = DNS:localhost, DNS:myalt, DNS:host.docker.internal"
12+
13+
server.crt:
14+
openssl req -x509 -newkey rsa:4096 -keyout server.key -out server.crt -sha256 -days 7650 \
15+
-subj "/C=US/ST=California/L=San Jose/O=LOCALSERVER/OU=Com/CN=localhost" -nodes \
16+
-addext "subjectAltName = DNS:localhost, DNS:host.docker.internal"
17+
18+
run_validation_server_self_sign_mtls: server.crt client.crt
19+
openssl s_server -accept 9443 -cert server.crt -key server.key -Verify 2 -CAfile client.crt $(DEBUG) -www
20+
21+
run_validation_client_self_sign_mtls: client.crt
22+
curl --cert client.crt --key client.key --cacert server.crt https://localhost:9443 -debug
23+
24+
run_validation_server_self_sign: server.crt
25+
openssl s_server -accept 8443 -cert server.crt -key server.key $(DEBUG) -www
26+
27+
clean:
28+
rm -f server.crt server.key client.crt client.key
29+
30+
env: ../.env
31+
32+
../.env: client.crt server.crt
33+
( echo STEPZEN_CLIENT_CRT=\""`cat client.crt`"\"; \
34+
echo STEPZEN_CLIENT_KEY=\""`cat client.key`"\"; \
35+
echo STEPZEN_SERVER_CRT=\""`cat server.crt`"\") > ../.env

rest/tls/tls.graphql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
type Query {
2+
"""
3+
will contact localhost using host.docker.internal and 8443 and selfsign configuration
4+
the ecmascript is used to repackage any content coming back (openssl s_server returns html)
5+
"""
6+
rest_self: JSON
7+
@rest(
8+
endpoint: "https://host.docker.internal:8443/"
9+
tls: "selfsign"
10+
ecmascript: """
11+
function transformREST(s) { return JSON.stringify({data100: s.length>100, accept_8443: s.includes("-accept 8443")})}
12+
"""
13+
)
14+
15+
"""
16+
will contact localhost using host.docker.internal and 9443 and mtls configuration
17+
the ecmascript is used to repackage any content coming back (openssl s_server returns html)
18+
"""
19+
rest_self_mtls: JSON
20+
@rest(
21+
endpoint: "https://host.docker.internal:9443/"
22+
tls: "selfsignedmtls"
23+
ecmascript: """
24+
function transformREST(s) { return JSON.stringify({data100: s.length>100, accept_9443: s.includes("-accept 9443")})}
25+
"""
26+
)
27+
}

0 commit comments

Comments
 (0)