importSpkiPemOrThrow
importSpkiPemOrThrow
Import a public key from PEM-encoded SubjectPublicKeyInfo.
ts
function importSpkiPemOrThrow(
pem: string,
algorithm?: PublicKeyImportInput,
): Promise<CryptoKey>Parameters
pem:stringalgorithm?:PublicKeyImportInput
See also
exportSpkiPemfor the inverse operation
Examples
ts
const pem = `-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...
-----END PUBLIC KEY-----`;
const key = await importSpkiPemOrThrow(pem, { kind: 'ecdsa', curve: 'P-256' });