RFR: 8365288: PEMDecoder should throw ClassCastException [v3]

Weijun Wang weijun at openjdk.org
Mon Aug 25 19:39:39 UTC 2025


On Tue, 19 Aug 2025 19:42:19 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

>> This bug fix is to change PEMDecoder.decode(..., Class<>) using PKCS8EncodedKeySpec and X509EncodedKeySpec will throw an IllegalArgumentException when the decoded data does not match. It should be ClassCastException.
>> 
>> Thanks
>> 
>> Tony
>
> Anthony Scarpino has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update test bugid

src/java.base/share/classes/java/security/PEMDecoder.java line 440:

> 438:                         .getKeySpec(key, X509EncodedKeySpec.class);
> 439:                 } else {
> 440:                     throw new IllegalArgumentException("Invalid KeySpec.");

Should this also be CCE?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26734#discussion_r2298957895


More information about the security-dev mailing list