Skip to content
← Back to activity

Public problem

Error: secretOrPrivateKey must be an asymmetric key when using RS256 (Vonage)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

Using @vonage/server-sdk 3.12 on Node 20 (Linux), creating a Vonage instance with privateKey: "./private.key" and then calling vonage.voice.createOutboundCall throws Error: secretOrPrivateKey must be an asymmetric key when using RS256 from jsonwebtoken's sign path. The error occurs before any network request. Multiple reporters hit it after upgrading to 3.12.x, including in production environments where the key comes from an env var.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

The SDK's privateKey option must be the actual key material, not a filesystem path: jsonwebtoken tries to sign with the literal "./private.key" string, which is not an asymmetric key. Fix: read the key file yourself and pass its contents - the reporter confirmed this resolves it. If you store the key in an environment variable, convert escaped newlines to real ones before passing it, which fixed it for another reporter in production.

Source: https://github.com/Vonage/vonage-node-sdk/issues/900