opentelemetry-collector icon indicating copy to clipboard operation
opentelemetry-collector copied to clipboard

Validate TLS config: return error if cert or key is missing

Open gupta-nu opened this issue 5 months ago • 9 comments
trafficstars

Description

If TLS is configured without a certificate or key, it currently fails at runtime with a TLS handshake error. current change fixes #13130 by adding a validation check in configtls.Config.Validate() to ensure that TLS configurations include both a certificate and a key.

missing certs caused confusing runtime handshake errors. With this change, users get clear validation error earlier.

Fixes #13130

gupta-nu avatar Jun 02 '25 17:06 gupta-nu

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: gupta-nu / name: Ananya Gupta (66157a2f772089502eff8529c0b690b91ee43185, 155d4e5d0fde163ef6b751846263244fd84d50c4, ba4f4e6bb7fc539494cc81c1b865d1fb22405d36, dffec0faf7606a565e33771a8af065d8b717bbe5, d813bb33a1b2c2ef52570dd48fe873b59c9f307e, 4df2df8ccef82d47b33fc99e00d6be102142ea5a)

Could you add a test?

dmathieu avatar Jun 03 '25 07:06 dmathieu

Added test TestConfig_Validate_CertKeyPresence in config_test.go to verify TLS cert/key combinations. Lmk if anymore adjustments are required!

gupta-nu avatar Jun 03 '25 08:06 gupta-nu

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.30%. Comparing base (c4c0814) to head (4df2df8). Report is 94 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13134      +/-   ##
==========================================
+ Coverage   91.28%   91.30%   +0.01%     
==========================================
  Files         508      509       +1     
  Lines       28661    28747      +86     
==========================================
+ Hits        26164    26248      +84     
- Misses       1980     1986       +6     
+ Partials      517      513       -4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 03 '25 08:06 codecov[bot]

This will need a changelog entry. And we should have another PR in contrib fixing the failing tests.

dmathieu avatar Jun 03 '25 09:06 dmathieu

Thks!! I've added a changelog entry to this PR. I'll open the separate PR to address failing tests there

gupta-nu avatar Jun 03 '25 09:06 gupta-nu

Hi! I've opened the contrib PR to fix the tests: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/40446 Please lmk if there are any changes required ,thnks!

gupta-nu avatar Jun 03 '25 10:06 gupta-nu

open-telemetry/opentelemetry-collector-contrib/pull/40452 will fix the contrib tests. I am working on it

mx-psi avatar Jun 03 '25 14:06 mx-psi

Please add changelog entry

bogdandrutu avatar Jun 05 '25 19:06 bogdandrutu

Superseded by #13245. continued the work as this PR was inactive.

areebahmeddd avatar Jun 21 '25 16:06 areebahmeddd

This PR was marked stale due to lack of activity. It will be closed in 14 days.

github-actions[bot] avatar Jul 08 '25 03:07 github-actions[bot]

Closing, as this has been superseded by #13245

dmathieu avatar Jul 08 '25 07:07 dmathieu