1

I'm having an issue with my Node.js application which uses the Google API to create a document on Google Drive. Everything works fine in my local environment, but when I deploy on Render.com, I encounter an OpenSSL error.

Here is the relevant code:


const { google } = require("googleapis");
require("dotenv").config();

async function uploadToDocs(content, isTest) {
  const google_private_key = process.env.google_private_key.replace(/\\n/g, "\n");
  console.log(  google_private_key)
  try {
    const jwtClient = new google.auth.JWT(
      process.env.google_client_email,
      null,
      process.env.google_private_key,
      [
        "https://www.googleapis.com/auth/documents",
        "https://www.googleapis.com/auth/drive",
      ],
      null
    );

    await jwtClient.authorize();

    console.log("authorized");

    return await createReport(jwtClient, content, isTest);
  } catch (err) {
    console.error("Error in uploadToDocs:", err);
  }
}

And my .env file:


google_private_key="-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSj ... sg=\n-----END PRIVATE KEY-----\n"
google_client_email=service-account@gatecap-automations.iam.gserviceaccount.com

The error arises when the application attempts to authenticate the JWT client with Google's service. The error thrown is related to OpenSSL's decoder routines: error:1E08010C:DECODER routines::unsupported.

Here's the error stack trace:


Error in uploadToDocs: Error: error:1E08010C:DECODER routines::unsupported at Sign.sign (node:internal/crypto/sig:131:29) at Object.sign (/usr/src/app/node_modules/jwa/index.js:152:45) at Object.jwsSign [as sign] (/usr/src/app/node_modules/jws/lib/sign-stream.js:32:24) at GoogleToken.requestToken (/usr/src/app/node_modules/gtoken/build/src/index.js:232:31) at GoogleToken.getTokenAsyncInner (/usr/src/app/node_modules/gtoken/build/src/index.js:166:21) at GoogleToken.getTokenAsync (/usr/src/app/node_modules/gtoken/build/src/index.js:145:55) at GoogleToken.getToken (/usr/src/app/node_modules/gtoken/build/src/index.js:97:21) at JWT.refreshTokenNoCache (/usr/src/app/node_modules/google-auth-library/build/src/auth/jwtclient.js:172:36) at JWT.refreshToken (/usr/src/app/node_modules/google-auth-library/build/src/auth/oauth2client.js:146:25) at JWT.authorizeAsync (/usr/src/app/node_modules/google-auth-library/build/src/auth/jwtclient.js:153:35) at JWT.authorize (/usr/src/app/node_modules/google-auth-library/build/src/auth/jwtclient.js:149:25) at uploadToDocs (/usr/src/app/newsLog/uploadToDocs.js:24:21) at /usr/src/app/app.js:35:25 at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at next (/usr/src/app/node_modules/express/lib/router/route.js:144:13) at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:114:3) at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) at /usr/src/app/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/usr/src/app/node_modules/express/lib/router/index.js:346:12) at next (/usr/src/app/node_modules/express/lib/router/index.js:280:10) at urlencodedParser (/usr/src/app/node_modules/body-parser/lib/types/urlencoded.js:82:7) at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5) { library: 'DECODER routines', reason: 'unsupported', code: 'ERR_OSSL_UNSUPPORTED' }

I have tried: -hardcoding the private key directly into the code. -switching from LibreSSL to OpenSSL locally to match the version on Render (OpenSSL 1.1.1n).

  • Adding quotes around the env variable in the service settings on Render. None of these actions changed or resolved the error.

I would appreciate any guidance or support!

0 Answers0