forked from instaclustr/cassandra-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eager reload if SSL communicaton fail due to race condition when cert is updated. Mute SSL errors caused by missbehaving clients.
- Loading branch information
Showing
7 changed files
with
245 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...src/main/java/com/zegelin/cassandra/exporter/netty/ssl/UnexpectedSslExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.zegelin.cassandra.exporter.netty.ssl; | ||
|
||
import io.netty.channel.ChannelHandlerAdapter; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.handler.codec.DecoderException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.net.ssl.SSLException; | ||
|
||
public class UnexpectedSslExceptionHandler extends ChannelHandlerAdapter { | ||
private static final Logger logger = LoggerFactory.getLogger(UnexpectedSslExceptionHandler.class); | ||
|
||
private final ReloadWatcher reloadWatcher; | ||
|
||
UnexpectedSslExceptionHandler(ReloadWatcher reloadWatcher) { | ||
this.reloadWatcher = reloadWatcher; | ||
} | ||
|
||
@Override | ||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) { | ||
try { | ||
if (unexpectedMessage(cause)) { | ||
logger.warn(cause.getMessage()); | ||
// This may indicate that we're currently using invalid combo of key & cert | ||
reloadWatcher.forceReload(); | ||
} | ||
} finally { | ||
ctx.fireExceptionCaught(cause); | ||
} | ||
} | ||
|
||
private boolean unexpectedMessage(Throwable cause) { | ||
return cause instanceof DecoderException | ||
&& cause.getCause() instanceof SSLException | ||
&& cause.getCause().getMessage().contains("unexpected_message"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.