Skip to content

fix(mqtt source): pass client certificates to rumqttc for mTLS#24929

Open
mr- wants to merge 3 commits intovectordotdev:masterfrom
mr-:fix-mqtt-mtls
Open

fix(mqtt source): pass client certificates to rumqttc for mTLS#24929
mr- wants to merge 3 commits intovectordotdev:masterfrom
mr-:fix-mqtt-mtls

Conversation

@mr-
Copy link

@mr- mr- commented Mar 14, 2026

Summary

This PR fixes a bug in the MQTT source where user-provided TLS client certificates (crt_file / key_file) were being silently ignored, breaking mTLS connections to strict brokers like AWS IoT Core.

Vector configuration


sources:
  aws_iot_subscriber:
    type: "mqtt"
    host: "foo-ats.iot.eu-central-1.amazonaws.com"
    port: 8883
    client_id: "MARTIN"

    topic:
      - "v1/sensors"


    tls:
      enabled: true
      ca_file:  "AmazonBundle.pem"
      crt_file: "AWS-IoT-Client.crt"
      key_file: "AWS-IoT-Client-pkcs8.key"
    decoding:
      codec: "bytes"


sinks:
  console_output:
    type: "console"
    inputs:
      - "aws_iot_subscriber"
    target: "stdout"
    encoding:
      codec: "text"

How did you test this PR?

It was tested manually by providing valid certificates.

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

Not sure. Not unless people depended on certificates being ignored.

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

Notes

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Some CI checks run only after we manually approve them.
    • We recommend adding a pre-push hook, please see this template.
    • Alternatively, we recommend running the following locally before pushing to the remote branch:
      • make fmt
      • make check-clippy (if there are failures it's possible some of them can be fixed with make clippy-fix)
      • make test
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run make build-licenses to regenerate the license inventory and commit the changes (if any). More details here.

@mr- mr- requested a review from a team as a code owner March 14, 2026 20:37
@github-actions github-actions bot added the domain: sources Anything related to the Vector's sources label Mar 14, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mr-
Copy link
Author

mr- commented Mar 14, 2026

@vectordotdev/vector when debugging this, I've noticed that all errors are silently ignored.
I've added logs now, but I'm not sure if there's more error handling that should be done. As far as I know, rumqttc's EventLoop/poll will try to reconnect, but not all errors are transient.

@mr-
Copy link
Author

mr- commented Mar 14, 2026

I have read the CLA Document and I hereby sign the CLA

@mr- mr- changed the title fix(mqtt): pass client certificates to rumqttc for mTLS fix(mqtt source): pass client certificates to rumqttc for mTLS Mar 14, 2026
Comment on lines +87 to +90
Err(e) => {
tracing::error!("Error = {e:?}");
return Ok(());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct since this will terminate the connection as soon as any error is received instead of continuing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. What should the behaviour be for non-recoverable errors? I won't implement this now, but I'd like to get a sense for what the proper solution is supposed to be

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we revert the changes to this file? They don't seem related to this PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. However, it's been extremely frustrating not being able to see what was going on. From a user perspective the mqtt sink just failed with no indication what might be wrong.

@thomasqueirozb thomasqueirozb added meta: awaiting author Pull requests that are awaiting their author. source: mqtt labels Mar 16, 2026
@github-actions github-actions bot removed the meta: awaiting author Pull requests that are awaiting their author. label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sources Anything related to the Vector's sources source: mqtt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants