Skip to content

Conversation

valyria257
Copy link
Collaborator

@valyria257 valyria257 commented Jun 5, 2025

This is a duplicate of #1079

Proposed changes

Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the supported keywords here in this description (not in the title of the PR).

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13
When generating a self-signed cert for _unit-tests_ it doesn't need to have high security. Using a smaller length makes the tests run faster. The difference is ~0.1s vs ~2.0s to run one test that generates a cert.
This was incorrectly passing in the cert and key backwards which resulted in not actually getting mTLS credentials, but instead insecure credentials. When insecure credentials are used, skipToken means we don't add a addPerRPCCredentials. When it is a secure TLS credential then addPerRPCCredentials increases the dialoption count by one.
This had been skipping out of the function early if a client key wasn't specified. I don't believe that's correct. If I[User] have specified specified a CA cert because the MPI server I'm trying to talk to is signed by a non-standard CA (e.g. N1 devenv) then it should be respected regardless of whether I've configured mTLS. Silently skipping the CA is really confusing and leads to > Failed to create connection" error="rpc error: code = Unavailable desc = connection error: desc = \"transport: authentication handshake failed: tls: failed to verify certificate: x509: certificate signed by unknown authority\" I've split out the getTLSConfigForCredentials to make it easier to test this translation. Once it is wrapped into a TransportCredential or a DialOption it's opaque and hard to verify.
Previously if a consumer specified the CA cert to verify the command connection but that CA wasn't valid then system would log at Debug (default hidden) and proceed anyways. I don't believe this is good behavior. If the consumer is directly specifying a CA cert then that is the CA that should be used, not silently ignored. This patch returns the error up, which is now caught and swallowed at a higher level, but at least it is more visible: > time=2025-05-21T15:41:33.547Z level=ERROR msg="Unable to add transport credentials to gRPC dial options, adding default transport credentials" error="invalid CA cert while building transport credentials: read CA file (/etc/nginx-agent/bad.crt): open /etc/nginx-agent/bad.crt: no such file or directory"
@valyria257 valyria257 requested a review from a team as a code owner June 5, 2025 17:26
@github-actions github-actions bot added the chore Pull requests for routine tasks label Jun 5, 2025
@dhurley dhurley added the v3.x Issues and Pull Requests related to the major version v3 label Jun 6, 2025
@dhurley dhurley merged commit b9b8428 into nginx:main Jun 6, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Pull requests for routine tasks v3.x Issues and Pull Requests related to the major version v3

5 participants