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

generateKeyPairSync not working on Deno 2 but Node v20 #26188

Closed
sant123 opened this issue Oct 12, 2024 · 0 comments · Fixed by #26231
Closed

generateKeyPairSync not working on Deno 2 but Node v20 #26188

sant123 opened this issue Oct 12, 2024 · 0 comments · Fixed by #26231
Assignees
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto

Comments

@sant123
Copy link

sant123 commented Oct 12, 2024

From #18455 (comment)

Version: Deno 2

Running this code:

import { generateKeyPairSync } from "node:crypto";

const passphrase = "mypassphrase";
const cipher = "aes-256-cbc";
const modulusLength = 4096;

const key = generateKeyPairSync("rsa", {
  modulusLength,
  publicKeyEncoding: {
    type: "spki",
    format: "pem",
  },
  privateKeyEncoding: {
    type: "pkcs8",
    format: "pem",
    cipher,
    passphrase,
  },
});

console.log(key);

Fails on Deno but Node with the following error:

error: Uncaught (in promise) Error: PEM error: PEM Base64 error: invalid Base64 length
const key = generateKeyPairSync("rsa", {
            ^
    at PrivateKeyObject.export (ext:deno_node/internal/crypto/keys.ts:454:14)
    at generateKeyPairSync (ext:deno_node/internal/crypto/keygen.ts:74:37)

image

Thanks 🙏🏼

@littledivy littledivy added bug Something isn't working correctly crypto Related to node:crypto or WebCrypto labels Oct 13, 2024
littledivy added a commit to littledivy/deno that referenced this issue Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly crypto Related to node:crypto or WebCrypto
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants