Skip to content

Commit

Permalink
Added changes for SSL in websocket2.1 with Netty
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacrivriv committed Apr 3, 2024
1 parent 93dd6e7 commit 096c551
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public enum ConfigElement {
public static final String HTTP_KEEP_ALIVE_HANDLER_NAME = "httpKeepAlive";
public static final String HTTP2_CLEARTEXT_UPGRADE_HANDLER_NAME = "H2C_UPGRADE_HANDLER";

long maxContentLength = Long.MAX_VALUE;
public static final long maxContentLength = Long.MAX_VALUE;

private HttpPipelineInitializer(HttpPipelineBuilder builder) {
Objects.requireNonNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.ibm.websphere.ras.TraceComponent;
import com.ibm.ws.http.netty.NettyHttpChannelConfig;
import com.ibm.ws.http.netty.pipeline.HttpPipelineInitializer;
import com.ibm.ws.http.netty.pipeline.inbound.LibertyHttpObjectAggregator;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpServerCodec;
Expand All @@ -34,13 +35,14 @@ public class LibertyNettyALPNHandler extends ApplicationProtocolNegotiationHandl
* Default to HTTP 2.0 for now
*/
public LibertyNettyALPNHandler(NettyHttpChannelConfig httpConfig) {
super(ApplicationProtocolNames.HTTP_2);
// super(ApplicationProtocolNames.HTTP_2);
super(ApplicationProtocolNames.HTTP_1_1);
this.httpConfig = httpConfig;
}

@Override
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
System.out.println("Configuring pipeline!!");
System.out.println("Configuring pipeline!! " + protocol);
if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(this, tc, "Configuring pipeline with HTTP 2 for incoming connection " + ctx.channel());
Expand All @@ -62,6 +64,9 @@ protected void configurePipeline(ChannelHandlerContext ctx, String protocol) thr
}
ctx.pipeline().addAfter(HttpPipelineInitializer.HTTP_ALPN_HANDLER_NAME, HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC, new HttpServerCodec());
ctx.pipeline().addAfter(HttpPipelineInitializer.NETTY_HTTP_SERVER_CODEC, HttpPipelineInitializer.HTTP_KEEP_ALIVE_HANDLER_NAME, new HttpServerKeepAliveHandler());
//TODO: this is a very large number, check best practice
ctx.pipeline().addAfter(HttpPipelineInitializer.HTTP_KEEP_ALIVE_HANDLER_NAME, null,
new LibertyHttpObjectAggregator(httpConfig.getMessageSizeLimit() == -1 ? HttpPipelineInitializer.maxContentLength : httpConfig.getMessageSizeLimit()));
System.out.println("Configured Http1 pipeline with " + ctx.pipeline().names());
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(this, tc, "Configured pipeline with " + ctx.pipeline().names());
Expand Down
2 changes: 1 addition & 1 deletion dev/com.ibm.ws.wsoc/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Service-Component: \
dynamic:='tcpOptions,httpOptions,sslOptions';\
modified:='modified'; \
optional:='sslOptions,sslSupport,nettyTlsProvider';\
greedy:='tcpOptions,httpOptions,sslOptions'; \
greedy:='nettyTlsProvider,tcpOptions,httpOptions,sslOptions'; \
properties:='service.vendor=IBM', \
${bSymbolicName}_${replace;${bVersion};\\.;_}.ResourceProvider; \
implementation:=com.ibm.wsspi.classloading.ResourceProvider; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ protected void initChannel(Channel ch) throws Exception {
// TODO enable SSL
if (requestor.endpointAddress.isSecure()) {
SSLEngine engine = null;
if(requestor.endpointAddress instanceof Wsoc21Address) {
System.out.println("Attempting to pull sslcontext from Wsoc21Address");
engine = ((Wsoc21Address) requestor.endpointAddress).getSSLContext().createSSLEngine();
engine.setUseClientMode(true);
System.out.println("Pulled engine: " + Objects.nonNull(engine));
}
// if(requestor.endpointAddress instanceof Wsoc21Address) {
// System.out.println("Attempting to pull sslcontext from Wsoc21Address");
// engine = ((Wsoc21Address) requestor.endpointAddress).getSSLContext().createSSLEngine();
// engine.setUseClientMode(true);
// System.out.println("Pulled engine: " + Objects.nonNull(engine));
// }


if (Objects.isNull(engine) &&( WsocOutboundChain.currentSSL == null || WsocOutboundChain.getNettyTlsProvider() == null)) { // This shouldn't happen
Expand Down

0 comments on commit 096c551

Please sign in to comment.