Skip to content

Commit

Permalink
fix #227: Introduce properties for enabling ssl debugging
Browse files Browse the repository at this point in the history
(Tcp|Udp|Http)Client/Server#wiretap will add to the pipeline
SslLoggingHandler when reactor.netty.tcp.ssl.client.debug/
reactor.netty.tcp.ssl.server.debug system properties are enabled.
It will be placed before SslHandler.
  • Loading branch information
violetagg authored and smaldini committed Jan 18, 2018
1 parent 360f1d9 commit 5fbdd22
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/reactor/ipc/netty/channel/BootstrapHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
*/
public abstract class BootstrapHandlers {

static final boolean SSL_CLIENT_DEBUG =
Boolean.parseBoolean(System.getProperty("reactor.netty.tcp.ssl.client.debug",
"false"));

static final boolean SSL_SERVER_DEBUG =
Boolean.parseBoolean(System.getProperty("reactor.netty.tcp.ssl.server.debug",
"false"));

/**
* Finalize a server bootstrap pipeline configuration by turning it into a {@link
* ChannelInitializer} to safely initialize each child channel.
Expand Down Expand Up @@ -277,7 +285,7 @@ public static ServerBootstrap updateConfiguration(ServerBootstrap b,
* @return a mutated {@link Bootstrap#handler}
*/
public static Bootstrap updateLogSupport(Bootstrap b, LoggingHandler handler) {
updateConfiguration(b, NettyPipeline.LoggingHandler, logConfiguration(handler));
updateConfiguration(b, NettyPipeline.LoggingHandler, logConfiguration(handler, SSL_CLIENT_DEBUG));
return b;
}

Expand All @@ -291,7 +299,7 @@ public static Bootstrap updateLogSupport(Bootstrap b, LoggingHandler handler) {
*/
public static ServerBootstrap updateLogSupport(ServerBootstrap b,
LoggingHandler handler) {
updateConfiguration(b, NettyPipeline.LoggingHandler, logConfiguration(handler));
updateConfiguration(b, NettyPipeline.LoggingHandler, logConfiguration(handler, SSL_SERVER_DEBUG));
return b;
}

Expand Down Expand Up @@ -333,11 +341,11 @@ static ChannelHandler updateConfiguration(@Nullable ChannelHandler handler,
return p;
}

static BiConsumer<ConnectionEvents, ? super Channel> logConfiguration(LoggingHandler handler) {
static BiConsumer<ConnectionEvents, ? super Channel> logConfiguration(LoggingHandler handler, boolean debugSsl) {
Objects.requireNonNull(handler, "loggingHandler");
return (listener, channel) -> {
if (channel.pipeline().get(NettyPipeline.SslHandler) != null) {
if (log.isTraceEnabled()) {
if (debugSsl) {
channel.pipeline()
.addBefore(NettyPipeline.SslHandler,
NettyPipeline.SslLoggingHandler,
Expand Down

0 comments on commit 5fbdd22

Please sign in to comment.