Skip to content

Commit

Permalink
Add "MTLS" configuration to the service. (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanpf authored Nov 8, 2023
1 parent 443561f commit 43e718c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pjs/http/forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,19 @@
) : !proxyPreserveHostCache.get(__route) && (
msg.head.headers.host = __target
),
__useSSL = Boolean(attrs?.UseSSL),
attrs?.UpstreamCert ? (
__cert = attrs?.UpstreamCert
) : (
__cert = __service?.UpstreamCert
),
__cert ? (
!__service?.MTLS && (
__useSSL = true,
__cert = null
)
) : (
__useSSL = Boolean(attrs?.UseSSL)
),
_cookieId ? (
_cookieId = null
) : (
Expand Down
1 change: 1 addition & 0 deletions pjs/lib/connect-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
),
() => __useSSL, (
$=>$.connectTLS({
trusted: unionCA,
sni: () => __host || '',
}).to($ => $.use('lib/connect-tcp.js'))
),
Expand Down
3 changes: 3 additions & 0 deletions tests/shpec/config/metrics-tracing-logging_shpec/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@
}
},
"www8846": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand All @@ -709,6 +710,7 @@
}
},
"www8847": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand Down Expand Up @@ -744,6 +746,7 @@
}
},
"bookstore/bookstore-v1|14001|local": {
"MTLS": true,
"Endpoints": {
"127.0.0.3:8850": {
"Weight": 100,
Expand Down
3 changes: 3 additions & 0 deletions tests/shpec/config/mtls-client_shpec/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
}
},
"www8846": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand All @@ -421,6 +422,7 @@
}
},
"www8847": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand Down Expand Up @@ -456,6 +458,7 @@
}
},
"bookstore/bookstore-v1|14001|local": {
"MTLS": true,
"Endpoints": {
"127.0.0.3:8850": {
"Weight": 100,
Expand Down
3 changes: 3 additions & 0 deletions tests/shpec/config/mtls-upstream_shpec/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@
}
},
"www8846": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand All @@ -421,6 +422,7 @@
}
},
"www8847": {
"MTLS": true,
"Endpoints": {
"127.0.0.1:8850": {
"Weight": 100,
Expand Down Expand Up @@ -456,6 +458,7 @@
}
},
"bookstore/bookstore-v1|14001|local": {
"MTLS": true,
"Endpoints": {
"127.0.0.3:8850": {
"Weight": 100,
Expand Down

0 comments on commit 43e718c

Please sign in to comment.