Skip to content

Commit

Permalink
feat: Automatically set tls.servername option with rediss:// URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow committed Aug 20, 2019
1 parent 0d190ec commit 90040f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/redis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions test/unit/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 90040f9

Please sign in to comment.