node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

cannot connect with tls to Redis Cloud

Open MayasHaddad opened this issue 2 years ago • 3 comments

I followed both examples with the credentials generated here (tried with both "enforce client authentication" options)

I am able to successfully using redis-cli

But when I try to login using node-redis:

createClient({
      url,
      socket: {
        tls: true,
        cert: readFileSync(
          'redislabs_credentials/redislabs_user.crt',
        ),
        ca: readFileSync(
          'redislabs_credentials/redislabs_ca.pem',
        ),
      },
    });

I get:

ReplyError: ERR unencrypted connection is prohibited
    at parseError (/Users/mayas/bold/core/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/Users/mayas/bold/core/node_modules/redis-parser/lib/parser.js:302:14)

Environment:

  • Node.js Version: 16.3
  • Redis Server Version: 6.2.3
  • Node Redis Version: 4.0.4
  • Platform: Mac OS 11.4

MayasHaddad avatar Mar 10 '22 15:03 MayasHaddad

@MayasHaddad did you set the url prefix to rediss ?

gkorland avatar Mar 12 '22 21:03 gkorland

@gkorland yes. I set the value of url as described here

MayasHaddad avatar Mar 15 '22 16:03 MayasHaddad

@MayasHaddad you need to add the key as well:

createClient({
      url,
      socket: {
        tls: true,
        cert: readFileSync(
          'redislabs_credentials/redislabs_user.crt',
        ),
+       key: readFileSync(
+         'redislabs_credentials/redislabs_user_private.key',
+       ),
        ca: readFileSync(
          'redislabs_credentials/redislabs_ca.pem',
        ),
      },
    });

jaschaio avatar Apr 03 '22 06:04 jaschaio