MtHorebSocialMedia / mhlc-web

0 stars 0 forks source link

SSL issue writing to google apis from Digital Ocean #74

Closed nthngalone closed 1 month ago

nthngalone commented 1 month ago

Issue with writing to google apis on Digital Ocean. The generated credentials.json file has a double slash on the new-line characters (\\n) in the private key. Not sure if that's causing an issue. Disabled the service for now.

[mhlc-web] [2024-10-26 17:11:14] node:internal/crypto/sig:128
[mhlc-web] [2024-10-26 17:11:14]   const ret = this[kHandle].sign(data, format, type, passphrase, rsaPadding,
[mhlc-web] [2024-10-26 17:11:14]                             ^
[mhlc-web] [2024-10-26 17:11:14] 
[mhlc-web] [2024-10-26 17:11:14] Error: error:1E08010C:DECODER routines::unsupported
[mhlc-web] [2024-10-26 17:11:14]     at Sign.sign (node:internal/crypto/sig:128:29)
[mhlc-web] [2024-10-26 17:11:14]     at Object.sign (/workspace/node_modules/jwa/index.js:152:45)
[mhlc-web] [2024-10-26 17:11:14]     at Object.jwsSign [as sign] (/workspace/node_modules/jws/lib/sign-stream.js:32:24)
[mhlc-web] [2024-10-26 17:11:14]     at GoogleToken._GoogleToken_requestToken (/workspace/node_modules/gtoken/build/src/index.js:235:27)
[mhlc-web] [2024-10-26 17:11:14]     at GoogleToken._GoogleToken_getTokenAsyncInner (/workspace/node_modules/gtoken/build/src/index.js:180:97)
[mhlc-web] [2024-10-26 17:11:14]     at GoogleToken._GoogleToken_getTokenAsync (/workspace/node_modules/gtoken/build/src/index.js:160:173)
[mhlc-web] [2024-10-26 17:11:14]     at GoogleToken.getToken (/workspace/node_modules/gtoken/build/src/index.js:110:102)
[mhlc-web] [2024-10-26 17:11:14]     at JWT.refreshTokenNoCache (/workspace/node_modules/google-auth-library/build/src/auth/jwtclient.js:173:36)
[mhlc-web] [2024-10-26 17:11:14]     at JWT.refreshToken (/workspace/node_modules/google-auth-library/build/src/auth/oauth2client.js:187:24)
[mhlc-web] [2024-10-26 17:11:14]     at JWT.getRequestMetadataAsync (/workspace/node_modules/google-auth-library/build/src/auth/oauth2client.js:333:28) {
[mhlc-web] [2024-10-26 17:11:14]   library: 'DECODER routines',
[mhlc-web] [2024-10-26 17:11:14]   reason: 'unsupported',
[mhlc-web] [2024-10-26 17:11:14]   code: 'ERR_OSSL_UNSUPPORTED'
[mhlc-web] [2024-10-26 17:11:14] }
nthngalone commented 1 month ago

The double slash definitely is causing the error - was able to reproduce locally.

nthngalone commented 1 month ago

it's an issue with pulling environment variables from the OS - they get escaped automatically. dotenv apparently works around this. more research needed. leaving analytics disabled for now.

nthngalone commented 1 month ago

base64 encoding the private key was the easiest option that will work for local and deployed versions.