Skip to content

Connect Sentinel via TLS doesn't update servername for Redis had picked #1832

@anhhai2810

Description

@anhhai2810
const config_sentinel = {
    sentinels: sentinels,
    sentinelPassword: '123456',
    sentinelTLS: {
        ca: 'cert',
        rejectUnauthorized: false,
        servername: 'sentinel-pro.svc.local'
    },
    password: '123456',
    name: 'mymaster',
    role: 'master',
    enableTLSForSentinelMode: true,
    tls:  {
        ca: 'cert',
        rejectUnauthorized: false,
        servername: 'redis-master-pro.svc.local'
    },
}

We have 1 Master and 2 slaves
When Sentinel pick a node Redis to create a connection with TLS. At that time we can not use "config_sentinel.tls.servername" because server info may different to our config.
So, i try modify at "node_modules\ioredis\built\connectors\SentinelConnector\index.js":

if (this.options.enableTLSForSentinelMode && this.options.tls) {
                    debug("Update TLS servername >>>", resolved.host);
                    **this.options.tls.servername = resolved.host;**
                    Object.assign(resolved, this.options.tls);
                    this.stream = (0, tls_1.connect)(resolved);
                    this.stream.once("secureConnect", this.initFailoverDetector.bind(this));

I hope this issue can be fixed from next Pull Request!

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions