protected void verifyIdentityKey(PublicKey publicKey) throws ConnectionHandshakeException {
if(!(publicKey instanceof RSAPublicKey)) {
throw new ConnectionHandshakeException("Identity certificate public key is not an RSA key as expected");
}
final TorPublicKey identityKey = new TorPublicKey((RSAPublicKey)publicKey);
final Router router = connection.getRouter();
if((router instanceof BridgeRouter) && (router.getIdentityHash() == null)) {
logger.info("Setting Bridge fingerprint from connection handshake for "+ router);
((BridgeRouter) router).setIdentity(identityKey.getFingerprint());
} else if(!identityKey.getFingerprint().equals(router.getIdentityHash())) {
throw new ConnectionHandshakeException("Router identity does not match certificate key");
}
}