From 90040f97e544ab45218ac3474e0a884263606ac7 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Tue, 20 Aug 2019 18:18:40 +0100 Subject: [PATCH] feat: Automatically set tls.servername option with rediss:// URLs --- lib/redis/index.ts | 2 +- test/unit/redis.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/redis/index.ts b/lib/redis/index.ts index 7c9e64a88..8e91bc331 100644 --- a/lib/redis/index.ts +++ b/lib/redis/index.ts @@ -212,7 +212,7 @@ Redis.prototype.parseOptions = function() { } } if (isTls) { - defaults(this.options, {tls: true}) + defaults(this.options, {tls: {servername: this.options.host}}) } defaults(this.options, Redis.defaultOptions); diff --git a/test/unit/redis.ts b/test/unit/redis.ts index 655fa5d35..5a8409abf 100644 --- a/test/unit/redis.ts +++ b/test/unit/redis.ts @@ -81,11 +81,11 @@ describe("Redis", function() { }); expect(option).to.have.property("port", 6380); - option = getOption("rediss://host") - expect(option).to.have.property("tls", true) + option = getOption("rediss://host.test"); + expect(option.tls).to.deep.equal({servername: "host.test"}); - option = getOption("rediss://example.test", { tls: { hostname: "example.test" } }); - expect(option.tls).to.deep.equal({hostname: "example.test"}) + option = getOption("rediss://example.test", { tls: { rejectUnauthorized: false } }); + expect(option.tls).to.deep.equal({ rejectUnauthorized: false }); } catch (err) { stub.restore(); throw err;