azexcy commented on code in PR #22740:
URL: https://github.com/apache/shardingsphere/pull/22740#discussion_r1042987027
##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java:
##########
@@ -270,6 +280,10 @@ private final class MySQLBinlogEventHandler extends
ChannelInboundHandlerAdapter
private AbstractBinlogEvent lastBinlogEvent;
Review Comment:
It's update at `channelRead`, should we add final and use setter update
lastBinlogEvent?
##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/PasswordEncryption.java:
##########
@@ -107,7 +107,7 @@ private static RSAPublicKey parseRSAPublicKey(final String
key) throws GeneralSe
private static byte[] formatKey(final String key) {
int start = key.indexOf("\n") + 1;
- int end = key.lastIndexOf("\n");
+ int end = key.endsWith("\n") ? key.substring(0, key.length() -
2).lastIndexOf("\n") : key.lastIndexOf("\n");
return key.substring(start, end).replace("\n", "").getBytes();
Review Comment:
the `publicKeyRequested` property determines whether rsa is required
```
private void handleCachingSha2Auth(final ChannelHandlerContext ctx,
final MySQLAuthMoreDataPacket authMoreData) {
// how caching_sha2_password works:
https://dev.mysql.com/doc/dev/mysql-server/8.0.11/page_caching_sha2_authentication_exchanges.html#sect_caching_sha2_info
if (!publicKeyRequested) {
if (PERFORM_FULL_AUTHENTICATION ==
authMoreData.getPluginData()[0]) {
publicKeyRequested = true;
ctx.channel().writeAndFlush(new
MySQLAuthSwitchResponsePacket(authMoreData.getSequenceId() + 1, new
byte[]{REQUEST_PUBLIC_KEY}));
}
} else {
ctx.channel().writeAndFlush(new
MySQLAuthSwitchResponsePacket(authMoreData.getSequenceId() + 1,
PasswordEncryption.encryptWithRSAPublicKey(password,
seed,
serverInfo.getServerVersion().greaterThanOrEqualTo(8, 0, 5) ?
"RSA/ECB/OAEPWithSHA-1AndMGF1Padding" : "RSA/ECB/PKCS1Padding",
new String(authMoreData.getPluginData()))));
}
}
```
2. seem i can use `trim()` before passing in the key parameter
##########
kernel/data-pipeline/dialect/mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClient.java:
##########
@@ -157,6 +158,7 @@ public synchronized void subscribe(final String
binlogFileName, final long binlo
dumpBinlog(binlogFileName, binlogPosition, queryChecksumLength());
log.info("subscribe binlog file: {}, position: {}", binlogFileName,
binlogPosition);
reconnectTimes.set(0);
+ running = true;
Review Comment:
Ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]