Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<fix>(build): update build for secure issues. #603

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ dependencies {
compile 'com.google.code.gson:gson:2.8.9'
compile 'org.apache.commons:commons-lang3:3.11'
compile 'com.fasterxml.jackson.core:jackson-databind:2.14.2' // must not lower than 2.11.0 to support abi translate
compile 'org.springframework.boot:spring-boot-starter-actuator:2.7.18'
compile ('org.springframework.boot:spring-boot-starter-actuator:2.7.18'){
exclude group: 'org.yaml', module: 'snakeyaml'
}
compile 'org.springframework.boot:spring-boot-configuration-processor:2.7.18'
compile 'org.springframework.boot:spring-boot-starter-log4j2:2.7.18'
compile 'org.springframework:spring-core:5.3.32'
Expand All @@ -166,6 +168,8 @@ dependencies {
// Use JUnit test framework
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.7.18'
testImplementation 'net.minidev:json-smart:2.4.9'
testImplementation 'com.jayway.jsonpath:json-path:2.9.0'
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.netty.handler.ssl.SslHandshakeCompletionEvent;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.util.AttributeKey;
import javax.net.ssl.SSLPeerUnverifiedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -59,14 +58,16 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
logger.info(" handshake success, host: {}, ctx: {}", node, hashCode);
try {
getChannelHandlerCallBack().onConnect(ctx, getConnectToServer());
} catch (SSLPeerUnverifiedException e1) {
} catch (Exception e1) {
logger.warn(
" handshake on connect exception, disconnect, host: {}, ctx: {}, cause: {}",
node,
hashCode,
e1.getCause());
ctx.disconnect();
ctx.close();
throw new RuntimeException(
"SSLPeerUnverifiedException, handshake on connect exception", e1);
}
} else {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,20 @@ private String bytesToHex(byte[] hashInBytes) {
return sb.toString();
}

private PublicKey fetchCertificate(ChannelHandlerContext ctx)
throws SSLPeerUnverifiedException {
private PublicKey fetchCertificate(ChannelHandlerContext ctx) throws Exception {
SslHandler sslhandler = ctx.channel().pipeline().get(SslHandler.class);

Certificate[] certs = sslhandler.engine().getSession().getPeerCertificates();
Certificate[] certs;
try {
certs = sslhandler.engine().getSession().getPeerCertificates();
} catch (SSLPeerUnverifiedException e) {
logger.error("fetchCertificate error", e);
throw new Exception("fetchCertificate error", e);
}
logger.info(
" ctx: {}, Certificate length: {}, pipeline sslHandlers: {}",
Objects.hashCode(ctx),
certs.length,
String.valueOf(ctx.channel().pipeline().names()));
ctx.channel().pipeline().names());

Certificate cert = certs[0];
PublicKey publicKey = cert.getPublicKey();
Expand All @@ -91,8 +95,7 @@ private PublicKey fetchCertificate(ChannelHandlerContext ctx)
* @return
* @throws SSLPeerUnverifiedException
*/
public Node channelContext2Node(ChannelHandlerContext context)
throws SSLPeerUnverifiedException {
public Node channelContext2Node(ChannelHandlerContext context) throws Exception {
if (null == context) {
return null;
}
Expand All @@ -105,8 +108,7 @@ public Node channelContext2Node(ChannelHandlerContext context)
return new Node(nodeID, host, port);
}

public void onConnect(ChannelHandlerContext ctx, boolean connectToServer)
throws SSLPeerUnverifiedException {
public void onConnect(ChannelHandlerContext ctx, boolean connectToServer) throws Exception {
Node node = channelContext2Node(ctx);
int hashCode = System.identityHashCode(ctx);

Expand All @@ -127,15 +129,9 @@ public void onConnect(ChannelHandlerContext ctx, boolean connectToServer)
callBack.onConnect(ctx, node);
} else {
try {
threadPool.execute(
new Runnable() {
@Override
public void run() {
callBack.onConnect(ctx, node);
}
});
threadPool.execute(() -> callBack.onConnect(ctx, node));
} catch (TaskRejectedException e) {
logger.warn(" TaskRejectedException: {} ", e);
logger.warn(" TaskRejectedException: ", e);
callBack.onConnect(ctx, node);
}
}
Expand Down
Loading