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

multiple client via same context. #3283

Open
Ajuz369 opened this issue Nov 21, 2024 · 1 comment
Open

multiple client via same context. #3283

Ajuz369 opened this issue Nov 21, 2024 · 1 comment

Comments

@Ajuz369
Copy link

Ajuz369 commented Nov 21, 2024

Hello,,
I have one threaded websocket client running, having multiple url. I need to write libwebsocket based client , which will send data to 5-6 urls.
Client also need to validate server certificates .mutual bverification is expected. and each clients are having discrete certificates .

Requirement is all having discrete connection params including the tls certificattes. i have seen in context info object is having placed holder for the certifiacte path. how will i pass that information in case of multiple certificates for each connection that are sharing same lws_context.?

I have seen in some recommendation using lws_host , stating that to use vhost functionality. any example to refer that ?

@lws-team
Copy link
Member

Just to be clear, lws is strictly single threaded, you can't randomly throw threads on it. You can use lws in its own thread, the same context, loop and thread for all the client connections, and then interact with other threads carefully, but all but lws_cancel_service() apis in lws must be called from the event loop thread.

There is no example that does exactly what you want because there's no simple way to do mutual auth, ie, no easy way to set up long term certs and a server and maintain it just in case someone wanting to do mutual auth turns up years later.

Grep for LWS_SERVER_OPTION_EXPLICIT_VHOSTS in the examples to see how to create multiple vhosts.

The minimum for mutual auth on the client side should look like test-apps/test-client.c line 744.

#if defined(LWS_WITH_TLS)
        if (use_ssl) {
                /*
                 * If the server wants us to present a valid SSL client certificate
                 * then we can set it up here.
                 */

                if (cert_path[0])
                        info.client_ssl_cert_filepath = cert_path;
                if (key_path[0])
                        info.client_ssl_private_key_filepath = key_path;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants