Skip to content

Commit e10a9fd

Browse files
Fix DNS resolution with host aliases + Fix TLS Verifiy on default transport (#92)
* Fix DNS resolution with host aliases * Disable TLS on the default transport if required
1 parent 6bf1fc0 commit e10a9fd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ COPY *.go ./
1313

1414
ARG TARGETOS TARGETARCH
1515
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o lk-jwt-service
16+
# set up nsswitch.conf for Go's "netgo" implementation
17+
# - https://github.com/golang/go/blob/go1.24.0/src/net/conf.go#L343
18+
RUN echo 'hosts: files dns' > /etc/nsswitch.conf
1619

1720
FROM scratch
1821

1922
COPY --from=builder /proj/lk-jwt-service /lk-jwt-service
2023
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
24+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
2125

2226
EXPOSE 8080
2327

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"log"
2424
"net/http"
2525
"os"
26+
"crypto/tls"
2627

2728
"time"
2829

@@ -64,6 +65,8 @@ func exchangeOIDCToken(
6465

6566
if skipVerifyTLS {
6667
log.Printf("!!! WARNING !!! Skipping TLS verification for matrix client connection to %s", token.MatrixServerName)
68+
// Disable TLS verification on the default HTTP Transport for the well-known lookup
69+
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{ InsecureSkipVerify: true }
6770
}
6871
client := fclient.NewClient(fclient.WithWellKnownSRVLookups(true), fclient.WithSkipVerify(skipVerifyTLS))
6972

0 commit comments

Comments
 (0)