Skip to content
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

[receiver/mongodb] TLS Settings Ignored in certain circumstances #12092

Closed
schmikei opened this issue Jul 5, 2022 · 0 comments · Fixed by #12093
Closed

[receiver/mongodb] TLS Settings Ignored in certain circumstances #12092

schmikei opened this issue Jul 5, 2022 · 0 comments · Fixed by #12093
Labels
bug Something isn't working

Comments

@schmikei
Copy link
Contributor

schmikei commented Jul 5, 2022

Describe the bug
Did some digging and noticed the alpha receiver/mongodbreceiver was checking for a non-nil error from configtls.LoadTLSConfig() before inputting into the mongo-go-driver

Steps to reproduce
Set up a mongodb 4.4 instance with these settings:

net:
   tls:
      mode: requireTLS
      certificateKeyFile: /opt/mongo/tls/mongo-test.localnet.pem
      allowConnectionsWithoutCertificates: true

And the mongod logs indicate a problem from the client:

{"t":{"$date":"2022-07-01T22:21:27.345+00:00"},"s":"I",  "c":"NETWORK",  "id":22988,   "ctx":"conn8528","msg":"Error receiving request from client. Ending connection from remote","attr":{"error":{"code":141,"codeName":"SSLHandshakeFailed","errmsg":"The server is configured to only allow SSL connections"},"remote":"127.0.0.1:58444","connectionId":8528}}

What did you expect to see?
Before:

        tlsConfig, err := c.LoadTLSConfig()
	if err != nil && tlsConfig != nil {
		clientOptions.SetTLSConfig(tlsConfig)
	}

After:

        tlsConfig, err := c.LoadTLSConfig()
	if err == nil && tlsConfig != nil {
		clientOptions.SetTLSConfig(tlsConfig)
	}

What did you see instead?
Metrics collection did work through TLS

What version did you use?
Version 0.54.0 version of the mongodbreceiver

What config did you use?

receivers:
  mongodb:
    hosts:
      - endpoint: keith-mongo-test.bluemedora.localnet:27017
    username: admin
    password: password
    collection_interval: 20s
    tls:
      insecure: false
      cert_file: /opt/mongo/tls/mongo-test.localnet.crt
      key_file: /opt/mongo/tls/mongo-test.localnet.key
      insecure_skip_verify: true
exporters:
  logging:

service:
  pipelines:
    metrics:
      receivers:
      - mongodb
      exporters:
      - logging

Environment
OS: "RHEL 7.9"

Additional context

Will author a PR shortly to resolve this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant