-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathpem-encoding.yaml
More file actions
50 lines (50 loc) · 1.53 KB
/
pem-encoding.yaml
File metadata and controls
50 lines (50 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
id: 76
slug: "pem-encoding"
title: "PEM encoding/decoding"
category: "security"
difficulty: "advanced"
jdkVersion: "25"
oldLabel: "Java 8"
modernLabel: "Java 25 (Preview)"
oldApproach: "Manual Base64 + Headers"
modernApproach: "PEM API"
oldCode: |-
String pem = "-----BEGIN CERTIFICATE-----\n"
+ Base64.getMimeEncoder()
.encodeToString(
cert.getEncoded())
+ "\n-----END CERTIFICATE-----";
modernCode: |-
// Encode to PEM
String pem = PEMEncoder.of()
.encodeToString(cert);
// Decode from PEM
var cert = PEMDecoder.of()
.decode(pemString);
summary: "Encode and decode PEM-formatted cryptographic objects natively."
explanation: "The PEM API provides standard encoding/decoding for certificates, keys,\
\ and other cryptographic objects in PEM format. No more manual Base64 wrapping\
\ with BEGIN/END headers."
whyModernWins:
- icon: "🧹"
title: "No manual Base64"
desc: "PEM headers, line wrapping, and Base64 handled automatically."
- icon: "🔄"
title: "Bidirectional"
desc: "Encode to PEM and decode from PEM with one API."
- icon: "🛡️"
title: "Standard format"
desc: "Produces RFC 7468-compliant PEM output."
support:
state: "preview"
description: "Preview in JDK 25 (JEP 470). Requires --enable-preview."
prev: "datetime/hex-format"
next: "security/key-derivation-functions"
related:
- "security/key-derivation-functions"
- "security/strong-random"
- "security/tls-default"
docs:
- title: "PEM Encodings of Certificates (JEP 470)"
href: "https://openjdk.org/jeps/470"