-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: add support for rediss protocol in url #1282
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
Conversation
I just wanted to start on working on the exact same thing. Some PaaS providers (e.g. Azure) default to make redis available through a TLS socket. Alongside the clients @calebboyd already mentioned, Predis (PHP) does the same. Would be cool to see this small change merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is almost LGTM with some nits.
What is still required is updating the documentation to add a part about what happens if you use rediss:
instead of redis:
including a note that TLS options have to be passed in with the tls
option if required.
README.md
Outdated
@@ -216,7 +216,7 @@ using unix sockets if possible to increase throughput. | |||
| host | 127.0.0.1 | IP address of the Redis server | | |||
| port | 6379 | Port of the Redis server | | |||
| path | null | The UNIX socket string of the Redis server | | |||
| url | null | The URL of the Redis server. Format: `[redis:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). | | |||
| url | null | The URL of the Redis server. Format: `[redis:][rediss:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]` (More info avaliable at [IANA](http://www.iana.org/assignments/uri-schemes/prov/redis)). | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please change this to the following?
[redis[s]:]//[[user][:password@]][host][:port][/db-number][?db=db-number[&password=bar[&option=value]]]
Right now the syntax would be wrong as it would actually "allow" redis:rediss://...
.
lib/createClient.js
Outdated
options.tls = options.tls || {}; | ||
} else { | ||
console.warn('node_redis: WARNING: You passed "' + parsed.protocol.substring(0, parsed.protocol.length - 1) + '" as protocol instead of the "redis" protocol!'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change this to the following:
if (parsed.protocol) {
if (parsed.protocol === 'rediss:') {
options.tls = ...
} else if (parsed.protocol !== 'redis:') {
console.warn('...')
}
}
test/tls.spec.js
Outdated
@@ -108,6 +108,29 @@ describe('TLS connection tests', function () { | |||
client.get('foo', helper.isString('bar', done)); | |||
}); | |||
|
|||
describe('using rediss as url protocol', function (done) { | |||
var tls = require('tls') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the require to the top of the file.
@BridgeAR updated! |
Use master version of Node Redis client for now, because TLS support is not yet officially released: redis/node-redis#1268 redis/node-redis#1282
Use master version of Node Redis client for now, because TLS support is not yet officially released: redis/node-redis#1268 redis/node-redis#1282
Use master version of Node Redis client for now, because TLS support is not yet officially released: redis/node-redis#1268 redis/node-redis#1282
@BridgeAR do you have any plans to publish a new version with this change? |
This adds the ability to pass
rediss
as the protocol for aredis_url
This functionality is common in several other redis clients (redis-py, lettuce, Jedis etc)
It is the equivalent of doing
It is useful when the the host is signed by a global CA, and no advanced (self signed etc) configuration is required.