8000 Fix verification in HTTP library. · bulejava/google-http-java-client@7548c14 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7548c14

Browse files
romanzhangejona86
authored andcommitted
Fix verification in HTTP library.
Clients get a list of public keys to verify the signed token, the client library will try all the keys one by one until it find a match. All these keys used to have the same size, 1024 bit. Recently we've made all the newly generated key with 2048 bit, so it's possible that a client get a list of two keys with the first key 1024 bit RSA and the second key 2048 bit RSA. If the blob was signed by the 1024 bit key, and the client tried the 2048 bit key first, an exception will be throw, and vice versa. The correct behavior is to ignore this exception and continue to try the next key. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=95790730
1 parent 8d2d6a8 commit 7548c14

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

google-http-client/src/main/java/com/google/api/client/util/SecurityUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ public static boolean verify(
161161
throws InvalidKeyException, SignatureException {
162162
signatureAlgorithm.initVerify(publicKey);
163163
signatureAlgorithm.update(contentBytes);
164-
return signatureAlgorithm.verify(signatureBytes);
164+
// SignatureException may be thrown if we are tring the wrong key.
165+
try {
166+
return signatureAlgorithm.verify(signatureBytes);
167+
} catch (SignatureException e) {
168+
return false;
169+
}
165170
}
166171

167172
/**

0 commit comments

Comments
 (0)
0