Return Value
A Data containing the original PEM bytes in UTF-8. Use it for persistence, transport to an HSM, or future provider-backed signing APIs.
Mentioned In
Discussion
Returns the UTF-8 encoding of the input string verbatim — not a re-serialized PEM, and not a DER blob. This is the form expected by keychain imports, HSM shims, and on-disk key storage formats that treat the PEM text as an opaque transport envelope. Because the storage is the user-provided input, header comments and vendor annotations outside the BEGIN/ END markers are preserved round-trip.
Important
The returned bytes contain private-key material. Never log this value, never include it in crash reports or analytics, and zero any backing buffer you copy it into before releasing the memory. Foundation’s Data does not zeroize on deinit.