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

Problems configuring faststream for SASL_SSL security #1405

Open
jorrgme opened this issue Apr 29, 2024 Discussed in #1404 · 1 comment
Open

Problems configuring faststream for SASL_SSL security #1405

jorrgme opened this issue Apr 29, 2024 Discussed in #1404 · 1 comment
Assignees
Labels
bug Something isn't working Confluent Issues related to `faststream.confluent` module

Comments

@jorrgme
Copy link

jorrgme commented Apr 29, 2024

Discussed in #1404

Originally posted by jorrgme April 29, 2024
Hi all,

I really need your help, as I've been trying everything to be able to consume from a topic using SASL_SSL authentication.

This is the code I'm using:

import ssl
from faststream import FastStream
from faststream.confluent import KafkaBroker
from faststream.security import SASLPlaintext

user      = "my_usr"
passw     = "my_pass"
bootstrap = "my.bootstrap.server.com:443"
cert      = "~/my_certs/CRT_cacerts.pem"
group     = "my_group"
topic     = "my.topic.cpd"

ssl_context = ssl.create_default_context(
    cafile=cert,
)
security = SASLPlaintext(
    ssl_context=ssl_context,
    username=user,
    password=passw,
    use_ssl=True
)

broker = KafkaBroker(
    bootstrap_servers=bootstrap,
    security=security,
)

app = FastStream(broker)

@broker.subscriber(topic, group_id=group)
async def handle_msg(data) -> str:
    print(data)

And this is the log with ssl verifying errors I'm getting:

2024-04-29 10:41:59,089 INFO     - FastStream app starting...
%3|1714380119.145|FAIL|faststream-0.5.2#producer-1| [thrd:sasl_ssl://my.bootstrap.server.com:443/bootstrap]: sasl_ssl://my.bootstrap.server.com:443/bootstrap: SSL handshake failed: error:0A000086:SSL routines::certificate verify failed: broker certificate could not be verified, verify that ssl.ca.location is correctly configured or root CA certificates are installed (brew install openssl) (after 9ms in state SSL_HANDSHAKE)

Does anyone have any idea of how I can solve my issues?

I've tried the same thing using Faust and it's working fine using the same certificate, user and password.

Thanks in advance for any help you can provide.

@Lancetnik
Copy link
Collaborator

Looks like we missed ssl_context option in the Confluent config: https://github.com/airtai/faststream/blob/main/faststream/confluent/client.py#L286

I should dig into a bit

@Lancetnik Lancetnik added Confluent Issues related to `faststream.confluent` module bug Something isn't working labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Confluent Issues related to `faststream.confluent` module
Projects
Status: In Progress
Development

No branches or pull requests

3 participants