Copilot commented on code in PR #3779:
URL: https://github.com/apache/brpc/pull/3779#discussion_r4718986827
##########
src/brpc/policy/mysql/mysql_auth_scramble.cpp:
##########
@@ -177,6 +283,12 @@ std::string CachingSha2PasswordRsaEncrypt(
return out;
}
+bool ServerPublicKeyMatches(const butil::StringPiece& server_pubkey_pem,
+ const butil::StringPiece& pinned_pubkey_pem) {
+ const std::string server_der = PublicKeyDer(server_pubkey_pem);
+ return !server_der.empty() && server_der ==
PublicKeyDer(pinned_pubkey_pem);
Review Comment:
This matcher now accepts `BEGIN RSA PUBLIC KEY` by wrapping its PKCS#1
bytes, but the full-auth path later passes the server PEM to
`CachingSha2PasswordRsaEncrypt`, which still loads it only with
`PEM_read_bio_PUBKEY`. A server that returns the PKCS#1 form—one of the formats
this helper explicitly accepts—will therefore pass the pin check and then fail
encryption instead of completing authentication. Parse/normalize the PKCS#1
form in the encryptor as well, or have the comparison/normalization produce a
key representation that the encryptor can consume.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]