Skip to content

Commit

Permalink
Merge pull request #5213 from kwvanderlinde/bugfix/5212-easy-connect-…
Browse files Browse the repository at this point in the history
…control-flow

Fix Easy Connect handshake control flow once public key is requested
  • Loading branch information
cwisniew authored Feb 13, 2025
2 parents 8d3bc2b + 44af534 commit e8e4579
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void onClose(int code, String reason, boolean remote) {
@Override
public void onError(Exception ex) {
lastError = "WebSocket error: " + ex.toString() + "\n";
log.error("S " + lastError);
log.error("S " + lastError, ex);
// onClose will be called after this method
}
};
Expand Down Expand Up @@ -147,7 +147,7 @@ public void onDataChannelOpened(WebRTCConnection connection) {
try {
fireClientConnect(connection);
} catch (Exception e) {
log.error(e);
log.error("Unexpected error while handling new data channel", e);
}
}

Expand Down
23 changes: 12 additions & 11 deletions src/main/java/net/rptools/maptool/server/ServerHandshake.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,18 +523,19 @@ private void sendAsymmetricKeyAuthType()
} else {
sendErrorResponseAndNotify(HandshakeResponseCodeMsg.INVALID_PUBLIC_KEY);
}
} else {
CipherUtil.Key publicKey = playerDatabase.getPublicKey(player, playerPublicKeyMD5).get();
String password = new PasswordGenerator().getPassword();
handshakeChallenges[0] =
HandshakeChallenge.createAsymmetricChallenge(player.getName(), password, publicKey);

var authTypeMsg =
UseAuthTypeMsg.newBuilder()
.setAuthType(AuthTypeEnum.ASYMMETRIC_KEY)
.addChallenge(ByteString.copyFrom(handshakeChallenges[0].getChallenge()));
var handshakeMsg = HandshakeMsg.newBuilder().setUseAuthTypeMsg(authTypeMsg).build();
sendMessage(State.AwaitingClientPublicKeyAuth, handshakeMsg);
}
CipherUtil.Key publicKey = playerDatabase.getPublicKey(player, playerPublicKeyMD5).get();
String password = new PasswordGenerator().getPassword();
handshakeChallenges[0] =
HandshakeChallenge.createAsymmetricChallenge(player.getName(), password, publicKey);

var authTypeMsg =
UseAuthTypeMsg.newBuilder()
.setAuthType(AuthTypeEnum.ASYMMETRIC_KEY)
.addChallenge(ByteString.copyFrom(handshakeChallenges[0].getChallenge()));
var handshakeMsg = HandshakeMsg.newBuilder().setUseAuthTypeMsg(authTypeMsg).build();
sendMessage(State.AwaitingClientPublicKeyAuth, handshakeMsg);
}

@Override
Expand Down

0 comments on commit e8e4579

Please sign in to comment.