Browse Source

Pull request #2840: DEC-19253 feat: netty-socketio支持配置加密套件

Merge in CORE/base-third from ~CLOUD.LIU/base-third:feature/10.0 to feature/10.0

* commit '29ae8b9775e8f7c97d9e43e0ea4be8dfdc9fa7d6':
  DEC-19253 feat: netty-socketio支持配置加密套件
feature/10.0
Cloud.Liu 3 years ago
parent
commit
227f2d5053
  1. 5
      fine-socketio/pom.xml
  2. 23
      fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java
  3. 10
      fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java

5
fine-socketio/pom.xml

@ -35,6 +35,11 @@
<artifactId>fine-spring</artifactId> <artifactId>fine-spring</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>com.fr.essential</groupId>
<artifactId>fine-common</artifactId>
<version>${essentialVersion}</version>
</dependency>
<!-->以下是lib的本地jar包依赖<--> <!-->以下是lib的本地jar包依赖<-->
<dependency> <dependency>
<groupId>com.fr.third</groupId> <groupId>com.fr.third</groupId>

23
fine-socketio/src/main/java/com/fr/third/socketio/Configuration.java

@ -98,6 +98,10 @@ public class Configuration {
private List<Interceptor> disconnectInterceptors = Collections.emptyList(); private List<Interceptor> disconnectInterceptors = Collections.emptyList();
private List<EventInterceptor> eventInterceptors = Collections.emptyList(); private List<EventInterceptor> eventInterceptors = Collections.emptyList();
private String[] nettyProtocols = new String[]{};
private String[] nettyCiphers = new String[]{};
public Configuration() { public Configuration() {
} }
@ -169,6 +173,9 @@ public class Configuration {
setConnectInterceptors(conf.getConnectInterceptors().toArray(new Interceptor[0])); setConnectInterceptors(conf.getConnectInterceptors().toArray(new Interceptor[0]));
setDisconnectInterceptors(conf.getDisconnectInterceptors().toArray(new Interceptor[0])); setDisconnectInterceptors(conf.getDisconnectInterceptors().toArray(new Interceptor[0]));
setEventInterceptors(conf.getEventInterceptors().toArray(new EventInterceptor[0])); setEventInterceptors(conf.getEventInterceptors().toArray(new EventInterceptor[0]));
setNettyProtocols(conf.getNettyProtocols());
setNettyCiphers(conf.getNettyCiphers());
} }
public JsonSupport getJsonSupport() { public JsonSupport getJsonSupport() {
@ -630,4 +637,20 @@ public class Configuration {
public void setEventInterceptors(EventInterceptor[] eventInterceptors) { public void setEventInterceptors(EventInterceptor[] eventInterceptors) {
this.eventInterceptors = Arrays.asList(eventInterceptors); this.eventInterceptors = Arrays.asList(eventInterceptors);
} }
public String[] getNettyProtocols() {
return nettyProtocols;
}
public void setNettyProtocols(String[] nettyProtocols) {
this.nettyProtocols = nettyProtocols;
}
public String[] getNettyCiphers() {
return nettyCiphers;
}
public void setNettyCiphers(String[] nettyCiphers) {
this.nettyCiphers = nettyCiphers;
}
} }

10
fine-socketio/src/main/java/com/fr/third/socketio/SocketIOChannelInitializer.java

@ -23,6 +23,7 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.TrustManagerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.third.socketio.scheduler.HashedWheelTimeoutScheduler; import com.fr.third.socketio.scheduler.HashedWheelTimeoutScheduler;
import com.fr.third.socketio.transport.PollingTransport; import com.fr.third.socketio.transport.PollingTransport;
import com.fr.third.socketio.transport.WebSocketTransport; import com.fr.third.socketio.transport.WebSocketTransport;
@ -155,6 +156,15 @@ public class SocketIOChannelInitializer extends ChannelInitializer<Channel> impl
if (sslContext != null) { if (sslContext != null) {
SSLEngine engine = sslContext.createSSLEngine(); SSLEngine engine = sslContext.createSSLEngine();
engine.setUseClientMode(false); engine.setUseClientMode(false);
if (ArrayUtils.isNotEmpty(configuration.getNettyProtocols())) {
engine.setEnabledProtocols(configuration.getNettyProtocols());
}
if (ArrayUtils.isNotEmpty(configuration.getNettyCiphers())) {
engine.setEnabledCipherSuites(configuration.getNettyCiphers());
}
pipeline.addLast(SSL_HANDLER, new SslHandler(engine)); pipeline.addLast(SSL_HANDLER, new SslHandler(engine));
} }
} }

Loading…
Cancel
Save