importSpkiDerOrThrow
Import a public key from DER-encoded SubjectPublicKeyInfo.
When algorithm is omitted, the algorithm (and, for EC keys, the curve) is inferred from the SPKI's own AlgorithmIdentifier — useful for keys whose type isn't known ahead of time. Pass algorithm to additionally assert that the DER matches an expected algorithm.
ts
function importSpkiDerOrThrow(
der: Uint8Array,
algorithm?: PublicKeyImportInput,
): Promise<CryptoKey>Parameters
der:Uint8Array— DER-encoded SubjectPublicKeyInfo bytesalgorithm?:PublicKeyImportInput— Optional expected algorithm; must match key contents when given
Returns — Extractable CryptoKey with verify usage
Throws
Error— If DER is malformed, encodes an unsupported algorithm, or doesn't matchalgorithm
See also
exportSpkiDerfor the inverse operationimportSpkiPemfor PEM input