TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
992 stars 309 forks source link

Pass custom CA to grpc dial option #7395

Closed KrishnaIyer closed 6 days ago

KrishnaIyer commented 6 days ago

Summary

Pass custom CA to grpc dial option, reverting: https://github.com/TheThingsNetwork/lorawan-stack/pull/7324/commits/b2b5d2c4f437488c0e446b29248cb50e042402a6

Changes

Testing

Locally

Steps
  1. Set a custom CA to the CLI
    export TTN_LW_CA=./ca.pem
  2. Test fetching a gateway.
Results

Before:

go run ./cmd/ttn-lw-cli gtw list
INFO    Telemetry is enabled. Check the documentation for more information on what is collected and how to disable it   {"documentation_url": "https://www.thethingsindustries.com/docs/reference/telemetry/cli"}
WARN    [core][Channel #1 SubChannel #2]grpc: addrConn.createTransport failed to connect to {Addr: "[::1]:8884", ServerName: "localhost:8884", }. Err: connection error: desc = "transport: authentication handshake failed: tls: failed to verify certificate: x509: “localhost” certificate is not trusted"
WARN    [core][Channel #1 SubChannel #2]grpc: addrConn.createTransport failed to connect to {Addr: "127.0.0.1:8884", ServerName: "localhost:8884", }. Err: connection error: desc = "transport: authentication handshake failed: tls: failed to verify certificate: x509: “localhost” certificate is not trusted"
WARN    Finished unary call {"duration": 0.0924, "error": "error:unknown:unknown (connection error: desc = \"transport: authentication handshake failed: tls: failed to verify certificate: x509: “localhost” certificate is not trusted\")", "error_correlation_id": "f9413aaa5fbb43159868c2b607b0da4a", "grpc.method": "List", "grpc.service": "ttn.lorawan.v3.GatewayRegistry", "grpc_code": "Unavailable", "namespace": "grpc"}
error:unknown:unknown (connection error: desc = "transport: authentication handshake failed: tls: failed to verify certificate: x509: “localhost” certificate is not trusted")
    correlation_id=f9413aaa5fbb43159868c2b607b0da4a

After

go run ./cmd/ttn-lw-cli gtw list
INFO    Telemetry is enabled. Check the documentation for more information on what is collected and how to disable it   {"documentation_url": "https://www.thethingsindustries.com/docs/reference/telemetry/cli"}
[]
INFO    New patch version available {"current": "3.32.1-dev", "docs_url": "https://www.thethingsindustries.com/docs/getting-started/upgrading/", "latest": "3.32.2"}
Regressions

This fixes a regression.

Notes for Reviewers

...

Checklist