Skip to content

[extension/opamp] TLS config loaded even for insecure schemes (ws/http) #39515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johannaojeling opened this issue Apr 21, 2025 · 2 comments · Fixed by #39516
Closed

[extension/opamp] TLS config loaded even for insecure schemes (ws/http) #39515

johannaojeling opened this issue Apr 21, 2025 · 2 comments · Fixed by #39516
Labels
bug Something isn't working extension/opamp needs triage New item requiring triage

Comments

@johannaojeling
Copy link
Contributor

Component(s)

extension/opamp

What happened?

Description

The OpAMP Agent Extension's OpAMP agent applies TLS settings even when the server::ws::endpoint/server::http::endpoint is set to a URL with ws/http scheme, resulting in the client being unable to connect to a server that uses an insecure protocol.

In the OpAMP Supervisor, a similar issue was addressed by loading the agent's TLS settings conditionally:

// determine if we need to load a TLS config or not
var tlsConfig *tls.Config
parsedURL, err := url.Parse(s.config.Server.Endpoint)
if err != nil {
return fmt.Errorf("parse server endpoint: %w", err)
}
if parsedURL.Scheme == "wss" || parsedURL.Scheme == "https" {
tlsConfig, err = s.config.Server.TLSSetting.LoadTLSConfig(context.Background())
if err != nil {
return err
}
}

A similar approach can be taken here.

Steps to Reproduce

Start an OpAMP server without TLS. If using the opamp-go example server, this can be done by replacing this line with:

_ = tlsConfig

Run the collector with the provided config from the OpenTelemetry Collector configuration section below:

./otelcol-contrib --config=./config.yaml

Expected Result

The collector connects to the OpAMP server.

Actual Result

The collector fails to connect to the OpAMP server.

It only connects if providing TLS config insecure: true:

extensions:
  opamp:
    server:
      ws:
        endpoint: "ws://127.0.0.1:4320/v1/opamp"
        tls:
          insecure: true

Collector version

v0.124.1

Environment information

Environment

OS: macOS Sequoia 15.4.1
Compiler: go1.24.2 darwin/arm64

OpenTelemetry Collector configuration

extensions:
  opamp:
    server:
      ws:
        endpoint: "ws://127.0.0.1:4320/v1/opamp"

receivers:
  nop:

exporters:
  nop:

service:
  extensions: [opamp]
  pipelines:
    traces:
      receivers: [nop]
      exporters: [nop]

Log output

2025-04-21T15:47:29.487+0200    info    [email protected]/service.go:199 Setting up own telemetry...
2025-04-21T15:47:29.487+0200    info    [email protected]/service.go:266 Starting otelcol-contrib...     {"Version": "0.124.1", "NumCPU": 11}
2025-04-21T15:47:29.487+0200    info    extensions/extensions.go:41     Starting extensions...
2025-04-21T15:47:29.487+0200    info    extensions/extensions.go:45     Extension is starting...
2025-04-21T15:47:29.509+0200    info    extensions/extensions.go:62     Extension started.
2025-04-21T15:47:29.510+0200    info    [email protected]/service.go:289 Everything is ready. Begin running and processing data.
2025-04-21T15:47:29.511+0200    error   [email protected]/opamp_agent.go:138      Failed to connect to the OpAMP server   {"error": "tls: first record does not look like a TLS handshake"}
github.com/open-telemetry/opentelemetry-collector-contrib/extension/opampextension.(*opampAgent).Start.func3
        github.com/open-telemetry/opentelemetry-collector-contrib/extension/[email protected]/opamp_agent.go:138
github.com/open-telemetry/opamp-go/client.(*wsClient).tryConnectOnce
        github.com/open-telemetry/[email protected]/client/wsclient.go:239
github.com/open-telemetry/opamp-go/client.(*wsClient).ensureConnected
        github.com/open-telemetry/[email protected]/client/wsclient.go:282
github.com/open-telemetry/opamp-go/client.(*wsClient).runOneCycle
        github.com/open-telemetry/[email protected]/client/wsclient.go:326
github.com/open-telemetry/opamp-go/client.(*wsClient).runUntilStopped
        github.com/open-telemetry/[email protected]/client/wsclient.go:412
github.com/open-telemetry/opamp-go/client/internal.(*ClientCommon).StartConnectAndRun.func1
        github.com/open-telemetry/[email protected]/client/internal/clientcommon.go:208

Additional context

No response

@johannaojeling johannaojeling added bug Something isn't working needs triage New item requiring triage labels Apr 21, 2025
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@johannaojeling
Copy link
Contributor Author

Self-assign

akshays-19 pushed a commit to akshays-19/opentelemetry-collector-contrib that referenced this issue Apr 23, 2025
…pen-telemetry#39516)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Loads TLS config for the OpAMP Extension's OpAMP agent only if the
`server::ws::endpoint`/`server::http::endpoint` config is set to a URL
with scheme `wss`/`https`.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#39515

<!--Describe what testing was performed and which tests were added.-->
#### Testing
- Added unit tests
- Tested manually with the steps described in **Steps to Reproduce** in
open-telemetry#39515

<!--Please delete paragraphs that you did not use before submitting.-->
Fiery-Fenix pushed a commit to Fiery-Fenix/opentelemetry-collector-contrib that referenced this issue Apr 24, 2025
…pen-telemetry#39516)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Loads TLS config for the OpAMP Extension's OpAMP agent only if the
`server::ws::endpoint`/`server::http::endpoint` config is set to a URL
with scheme `wss`/`https`.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#39515

<!--Describe what testing was performed and which tests were added.-->
#### Testing
- Added unit tests
- Tested manually with the steps described in **Steps to Reproduce** in
open-telemetry#39515

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extension/opamp needs triage New item requiring triage
Projects
None yet
1 participant