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

[Enhancement] SSLContext Initialize error #451

Closed
ruanwenjun opened this issue Jul 21, 2021 · 5 comments · Fixed by #458
Closed

[Enhancement] SSLContext Initialize error #451

ruanwenjun opened this issue Jul 21, 2021 · 5 comments · Fixed by #458
Labels
enhancement New feature or request
Milestone

Comments

@ruanwenjun
Copy link
Member

Currently, when we initialize the EventMeshHTTPServer it will throw an exception

2021-07-21 19:53:36,923 WARN  [eventMesh-http-server] http(SSLContextFactory.java:65) - sslContext init failed
java.nio.file.NoSuchFileException: eventmesh-runtime/conf/sChat2.jks
	at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86) ~[?:1.8.0_275]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:1.8.0_275]
	at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:1.8.0_275]
	at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) ~[?:1.8.0_275]
	at java.nio.file.Files.newByteChannel(Files.java:361) ~[?:1.8.0_275]
	at java.nio.file.Files.newByteChannel(Files.java:407) ~[?:1.8.0_275]
	at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384) ~[?:1.8.0_275]
	at java.nio.file.Files.newInputStream(Files.java:152) ~[?:1.8.0_275]
	at org.apache.eventmesh.runtime.boot.SSLContextFactory.getSslContext(SSLContextFactory.java:58) ~[eventmesh-runtime-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
	at org.apache.eventmesh.runtime.boot.AbstractHTTPServer.lambda$start$0(AbstractHTTPServer.java:159) ~[eventmesh-runtime-1.2.0-SNAPSHOT.jar:1.2.0-SNAPSHOT]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]

This caused by we delete the old sChat2.jks file, now if user don't set ssl.server.cer in env, or they don't add a sChat2.jks file to confPath, the exception will occur. It is maybe better to add a switch to control whether open SSL.

@ruanwenjun ruanwenjun added the enhancement New feature or request label Jul 21, 2021
@qqeasonchen
Copy link
Contributor

:( forget the ssl, update the jks file again, but it is time to add a ssl enable switch.

@lrhkobe
Copy link
Contributor

lrhkobe commented Jul 22, 2021

As to this question, EventMesh has a ssl enable switch and the default value is false.

The user guide of HTTPS can refer to the doc in docs/cn/features/https.zh-CN.md or docs/en/features/https.md

@ruanwenjun
Copy link
Member Author

@lrhkobe Yes, I got you. We may need to refactor this code.
The switch might should be moved to SSLContextFactory or AbrstractHTTPServer, otherwise, though we set the ssl switch false, it still throws an exception(Although this does not affect application).

@lrhkobe
Copy link
Contributor

lrhkobe commented Jul 22, 2021

@ruanwenjun I have not got you. Because I see the code which the switch is already in AbrstractHTTPServer.java.

public abstract class AbrstractHTTPServer extends AbstractRemotingServer {

    ...

    private boolean useTLS;

@ruanwenjun
Copy link
Member Author

@ruanwenjun Yes, you are right.
When the AbrstractHTTPServer.java start, it will new a HttpsServerInitializer and execute SSLContextFactory.getSslContext() to inject the SSLContext . The problem is in the getSslContext doesn't judge the ssl open.

image

It might be better to change the code to below:

SSLContext sslContext = useTLS ? SSLContextFactory.getSslContext() : null;
b.group(this.bossGroup, this.workerGroup)
        .channel(NioServerSocketChannel.class)
        .childHandler(new HttpsServerInitializer(sslContext)).childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);

ruanwenjun added a commit to ruanwenjun/incubator-eventmesh that referenced this issue Jul 22, 2021
@xwm1992 xwm1992 added this to the 1.3.0 milestone Dec 16, 2021
@xwm1992 xwm1992 changed the title SSLContext Initialize error [Enhancement] SSLContext Initialize error Dec 16, 2021
xwm1992 pushed a commit to xwm1992/EventMesh that referenced this issue Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants