Initializer
init(pemRepresentation:)
Parses an RSA public key from a PEM-encoded SPKI string.
init(pemRepresentation: String) throws
Parameters
-
pemRepresentation
-
The PEM-encoded SPKI public key. The RFC 7468 framing is mandatory; whitespace around the markers and inside the base64 body is permitted.
Mentioned In
Discussion
Performs outer-frame validation only: the input must be valid UTF-8 and must contain both a -----BEGIN marker and a PUBLIC KEY----- marker. The check is deliberately narrower than the private-key counterpart — a traditional PKCS#1 -----BEGIN RSA PUBLIC KEY----- header would pass the PUBLIC KEY----- substring test but is rejected by downstream consumers of pemData; normalize to SPKI before calling.
Warning
Validation is string-marker-only. A malformed SubjectPublicKeyInfo payload inside a valid PEM frame is not detected here. Future provider-backed verification will reject such inputs before use.
Throws
OpenSSLError.invalidKey(_:) if the input is not valid UTF-8 or lacks the expected frame markers.