Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CifR2BE7PBvRy5hT8TS9oz
25 lines
1.2 KiB
Plaintext
25 lines
1.2 KiB
Plaintext
$ java --enable-preview -cp ... RoundTrip (27.0.1.0.2+1)
|
|
== decode a public key, a private key and a certificate
|
|
RSA X.509 2048 bits
|
|
RSA PKCS#8
|
|
CN=localhost issued by CN=pem-api demo CA
|
|
== encode them again: the same text openssl wrote, apart from the line terminator
|
|
PEMEncoder line terminator is CRLF: true; the openssl file uses LF: true
|
|
ok: raw text differs from the file (CRLF vs LF)
|
|
ok: public key re-encodes to identical text once CRLF is normalised to LF
|
|
ok: private key re-encodes to identical text (LF-normalised)
|
|
ok: certificate re-encodes to identical text (LF-normalised)
|
|
== encode a key pair that was generated just now
|
|
[-----BEGIN PRIVATE KEY-----, -----END PRIVATE KEY-----]
|
|
line width of the Base64 body: 64
|
|
ok: private scalar survives the round trip
|
|
ok: public key survives the round trip
|
|
ok: ...but the private key's own encoding is not byte-for-byte the same (the PKCS#8 now carries the public key)
|
|
== what does decode(String) with no target class hand back?
|
|
rsa-public.pem -> PublicKey RSA
|
|
rsa-private-pkcs8.pem -> PrivateKey RSA
|
|
ed25519-private.pem -> PrivateKey EdDSA
|
|
server.pem -> X509Certificate CN=localhost
|
|
rsa-private-encrypted.pem -> EncryptedPrivateKeyInfo PBEWithHmacSHA256AndAES_256
|
|
exit=0
|