Skip to content

importPkcs8PemOrThrow ​

importPkcs8PemOrThrow ​

Import a private key from PEM-encoded PKCS#8 PrivateKeyInfo.

When algorithm is omitted, it is inferred from the key's own privateKeyAlgorithm (see importPkcs8DerOrThrow).

ts
function importPkcs8PemOrThrow(
	pem: string,
	algorithm?: PrivateKeyImportInput,
): Promise<CryptoKey>

Parameters

Examples

ts
const key = await importPkcs8PemOrThrow(pemString, { kind: 'ecdsa', curve: 'P-256' });
const inferred = await importPkcs8PemOrThrow(pemString);

Released under the MIT License.