Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rsa_import_pem_private_pkcs8 trimming fails #31

Open
ribizli opened this issue Apr 19, 2021 · 0 comments
Open

rsa_import_pem_private_pkcs8 trimming fails #31

ribizli opened this issue Apr 19, 2021 · 0 comments

Comments

@ribizli
Copy link
Contributor

ribizli commented Apr 19, 2021

-----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- are 27 + 25 = 52 characters.

But the code truncates 57 characters:

function rsa_import_pem_private_pkcs8(key: string): RSAKeyParams {
  const trimmedKey = key.substr(27, key.length - 57);
}

So I get the error InvalidCharacterError: The string to be decoded is not correctly encoded from atob.

My workaround is to add 5 more - at the end of the file. -----END PRIVATE KEY----------.

@ribizli ribizli mentioned this issue Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant