Skip to content

Commit eff4e24

Browse files
committed
fix: provide ssl engine with advisory peer and algorithm info
1 parent db4c019 commit eff4e24

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 6.4.3
2+
- Fix: provide SSL engine with advisory peer and algorithm information [#458](https://github.com/logstash-plugins/logstash-input-beats/issues/458)
3+
14
## 6.4.2
25
- Build: do not package jackson dependencies [#455](https://github.com/logstash-plugins/logstash-input-beats/pull/455)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.4.2
1+
6.4.3

src/main/java/org/logstash/netty/SslHandlerProvider.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import io.netty.handler.ssl.SslContext;
55
import io.netty.handler.ssl.SslHandler;
66

7+
import javax.net.ssl.SSLEngine;
8+
import javax.net.ssl.SSLParameters;
9+
import java.net.InetSocketAddress;
10+
711
public class SslHandlerProvider {
812

913
private final SslContext sslContext;
@@ -14,9 +18,20 @@ public SslHandlerProvider(SslContext context, int sslHandshakeTimeoutMillis){
1418
this.sslHandshakeTimeoutMillis = sslHandshakeTimeoutMillis;
1519
}
1620

17-
public SslHandler sslHandlerForChannel(final SocketChannel socket) {
18-
SslHandler handler = sslContext.newHandler(socket.alloc());
19-
handler.setHandshakeTimeoutMillis(sslHandshakeTimeoutMillis);
20-
return handler;
21+
public SslHandler sslHandlerForChannel(final SocketChannel socketChannel) {
22+
final InetSocketAddress remoteAddress = socketChannel.remoteAddress();
23+
final String peerHost = remoteAddress.getHostString();
24+
final int peerPort = remoteAddress.getPort();
25+
final SslHandler sslHandler = sslContext.newHandler(socketChannel.alloc(), peerHost, peerPort);
26+
27+
final SSLEngine engine = sslHandler.engine();
28+
engine.setUseClientMode(false);
29+
30+
final SSLParameters sslParameters = engine.getSSLParameters();
31+
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
32+
engine.setSSLParameters(sslParameters);
33+
34+
sslHandler.setHandshakeTimeoutMillis(sslHandshakeTimeoutMillis);
35+
return sslHandler;
2136
}
2237
}

0 commit comments

Comments
 (0)