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

why there is no documentation for enabling ssl in websocket server ? #882

Open
AhmedHumk opened this issue Jan 8, 2024 · 5 comments
Open

Comments

@AhmedHumk
Copy link

AhmedHumk commented Jan 8, 2024

currently i initiate my websocket server as following

tyrusServer = new Server("localhost", port, "/"+contextpath, null, ServerEndPoint_Jakarta.class);

I have checked the Tyrus Server properties it doesn't provide any ssl properties how to enable wss in tyrus server ?

@jansupol
Copy link
Contributor

jansupol commented Jan 9, 2024

Tyrus server is designed to be run in a container such as Servlet Container in an application server (Tomcat, Glassfish), or Grizzly (NIO server).

The SSL/TLS handshake occurs before the HTTP upgrade and it is handled by the container. Tyrus receives the HTTP request only after the SSL/TLS if that one is successful. Hence, the SSL/TLS needs to be configured for the container you run Tyrus in rather than for Tyrus Server itself.

@AhmedHumk
Copy link
Author

i couldnt figure out how to enable wss in my tyrus server i spent serveral days though.. i found a few snippets but how to assign it to the websocket server ?

                // SSL configuration
	        SSLContextConfigurator sslContext = new SSLContextConfigurator();
	        sslContext.setKeyStoreFile("path/to/keystore.jks");
	        sslContext.setKeyStorePass("keystore-password");
	        
	        // Set up SSL/TLS for Grizzly
	        SSLEngineConfigurator sslEngineConfigurator = new SSLEngineConfigurator(sslContext).setClientMode(false);


		tyrusServer = new Server("localhost", port, "/"+contextpath, serverProperties, ServerEndPoint_Jakarta.class);

@jansupol
Copy link
Contributor

You do not assign it to the WebSocket/Tyrus Server.
You do assign it:

  • to Glassfish (for instance here)
  • Or to Grizzly (the documentation)
  • Or to any other container Tyrus runs in.

@jansupol
Copy link
Contributor

You can see the Readme in the HTTPS example for Glassfish using the default certificate.

@AhmedHumk
Copy link
Author

I will move on from here ..since there is no accurate documentation for such important feature. Obviously that the websocket server in java is running under Grizzly Container which there is no way to get that container or event initiating custom one. i looked at the demo you have provided and all the links in the readme file to refer to SSL part are invalid. I have been sticking around Tyrus documentation for a while .. it lacks a lot of important stuff..

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