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

previously working rediss:// url does not work since 4.14.0 #940

Closed
mkls opened this issue Aug 5, 2019 · 2 comments · Fixed by #949
Closed

previously working rediss:// url does not work since 4.14.0 #940

mkls opened this issue Aug 5, 2019 · 2 comments · Fixed by #949
Labels

Comments

@mkls
Copy link

mkls commented Aug 5, 2019

Hello,

In 4.14.0 support for rediss:// url was introduced, but trying to connect to an url like this we get:

[ioredis] Unhandled error event: Error: unable to verify the first certificate

errors.

Before this version we used to have a workaround in our code for connecting to rediss:// urls which looked something like this:

const { URL } = require('url');
const redisUri = 'rediss://...'
const options = {
  lazyConnect: true,
  retryStrategy: () => 1000
};
if (redisUri.startsWith('rediss://')) {
  options.tls = { servername: new URL(redisUri).hostname };
}
const connection = new Redis(redisUri, options)

which was working fine. (even in local development where we had a regular redis:// url)

With this newly introduced feature I haven't been able to find the right options to make this work.

It looks like the new parser set's tls: true in options, and we would need more detailed config here.

@luin
Copy link
Collaborator

luin commented Aug 8, 2019

Just submitted a pull request for this issue.

For now, the workaround would be changing the protocol to redis:// after assigning tls:

if (redisUri.startsWith('rediss://')) {
  options.tls = { servername: new URL(redisUri).hostname };
  redisUri = redisUri.replace('rediss://', 'redis://')
}

After the pull request being merged, you can parse the tls option via URL directly:

const redisUri = 'rediss://127.0.0.1/?tls[servername]=127.0.0.1'
const options = {
  lazyConnect: true,
  retryStrategy: () => 1000
};

const connection = new Redis(redisUri, options)

@luin luin closed this as completed in #949 Aug 27, 2019
ioredis-robot pushed a commit that referenced this issue Aug 27, 2019
## [4.14.1](v4.14.0...v4.14.1) (2019-08-27)

### Bug Fixes

* don’t clobber passed-in tls options with rediss:/ URLs ([#949](#949)) ([ceefcfa](ceefcfa)), closes [#942](#942) [#940](#940) [#950](#950) [#948](#948)
@ioredis-robot
Copy link
Collaborator

🎉 This issue has been resolved in version 4.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment