RFR: 8365288: PEMDecoder should throw ClassCastException [v2]

Mikhail Yankelevich myankelevich at openjdk.org
Mon Aug 18 10:59:13 UTC 2025


On Tue, 12 Aug 2025 17:43:30 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:
> 
>   change to isInstance

test/jdk/java/security/PEM/PEMDecoderTest.java line 78:

> 76:         System.out.println("Decoder test rsaOpenSSL P1 PEM asking for RSAPublicKey.class returned:");
> 77:         testFailure(PEMData.rsaOpenSSL, RSAPublicKey.class);
> 78:         System.out.println("Decoder test rsapub PEM asking X509EKS.class returned:");

Please add a bug number to the `@bug`

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

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


More information about the security-dev mailing list