[gNMI] Verify optional client certificates - #780
Conversation
Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
Signed-off-by: Ashutosh Agrawal <ashu@cisco.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
This PR fixes the There is a related higher-impact issue worth tracking: in the SONiC image, # sonic-buildimage/dockers/docker-sonic-telemetry/telemetry.sh
CLIENT_AUTH=$(extract_field "$GNMI" ".client_auth")
if [ -z $CLIENT_AUTH ] || [ $CLIENT_AUTH == "false" ]; then
TELEMETRY_ARGS+=" --allow_no_client_auth"
fiThis makes the flag opt-out rather than opt-in for production devices — the binary-level description of "requires explicit operator configuration" understates the actual exposure. A separate PR to sonic-buildimage changing the condition to This PR is still the necessary complement: even when the flag is intentionally set, any presented certificate should be verified — which |
Why I did it
The gNMI server supports an optional client-certificate mode for deployments that use password, JWT, certificate, or mixed application authentication.
The current optional mode uses
tls.RequestClientCert. This asks the client for a certificate but does not verify a certificate when one is supplied. It also prevents certificate-based application authentication from receiving the verified certificate chain it requires.The optional mode should continue allowing clients without certificates while verifying any certificate that a client chooses to provide.
This change deliberately preserves the existing application-authentication policy. It does not require client certificates for password or JWT clients, reject configurations without application authentication, change listener binding, or modify the no-TLS behavior.
How I did it
tls.VerifyClientCertIfGivenwhen--allow_no_client_authis enabled.tls.RequireAndVerifyClientCertwhen optional mode is disabled.How to verify it
Results:
The new Go test file was formatted with
gofmt, andgit diff --checkpassed.Which release branch to backport (provide reason below if selected)
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO):
Failure type:
Tested branch
Test result
Description for the changelog
Verify client certificates supplied to the gNMI server when client certificates are optional.
Link to config_db schema for YANG module changes
N/A
A picture of a cute animal (not mandatory but encouraged)