RFR: 8298420: PEM API: Implementation (Preview) [v14]

Weijun Wang weijun at openjdk.org
Thu May 1 17:50:57 UTC 2025


On Thu, 1 May 2025 00:25:38 GMT, Anthony Scarpino <ascarpino at openjdk.org> wrote:

>> Yes, this method is private. But you allow `PEMEncoder().of().encode(PEMRecord)`. People might wonder why their leading data is lost.
>
> Then they can call PEMRecord.leadingData().

They can. Just tell them.

>> I meant the newline char at the end (before the "------BEGIN" chars). I just tried out your implementation, and noticed if there is nothing there, then `leadingData` is null; and if there is a line of text, `leadingData` contains the newline char at the end.
>> 
>> I still think this is worth mentioning. Suppose someone wants to rewrite the PEM file with the leading data, they need to know they should not use `println`.
>> 
>> BTW, I prefer trimming that newline char. Just my opinion.
>
> I see your point now, but `leadingData` is a byte array.  If an app wrote the `leadingData` in a `ByteArrayInputStream`, followed by the PEM text, it would not be the same data written as the newline would be gone.  Correct?

Why would it be gone? It's a 0x10 at the end of the byte array.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17543#discussion_r2070577038
PR Review Comment: https://git.openjdk.org/jdk/pull/17543#discussion_r2070576217


More information about the security-dev mailing list