João Casarin
João Casarin

Reputation: 916

Couchbase Sync Gateway randomly failing to authenticate using mTLS

We use this way to configure our Sync Gateway with Couchbase: documentation

Recently I had to change the way my Sync Gateway authenticate to Couchbase from user+pw to mTLS.

Previously, my config schema was like this:

{
    "use_tls_server": false,
    "databases": {
        "db2": {
            "username": "mySGuser",
            "password": "mySGpassword",
        },
    },
}

And now I changed it to:

{
    "use_tls_server": true,
    "databases": {
        "db2": {
            "cacertpath": "/etc/certs/truststore.pem",
            "certpath": "/etc/certs/sg_client.pem",
            "keypath": "/etc/certs/sg_client.key"
        },
    },
}

The problem is that it did work when I changed the connection from my server with couchbase (the API source-code part), and it also did work when I changed the Sync Gateway configs. However (a BIG one), our sync-gateway pod on K8S fail very often the authentication, giving me this error:

2024-03-18T12:32:39.457Z [ERR] c:#1003 #1003: authentication failure |
{
    "design_document_name": "mySearch",
    "view_name": "users",
    "errors": [
        {
            "SourceNode": "reason",
            "Message": "password required"
        },
        {
            "SourceNode": "error",
            "Message":"unauthorized"
        }
    ]
} -- rest.(*handler).writeError() at handler.go:1107
2024-03-18T12:32:39.457Z [INF] HTTP: #1003:     --> 500 Internal error: authentication failure | {"design_document_name":"mySearch","view_name":"users","errors":[{"SourceNode":"reason","Message":"password required"},{"SourceNode":"error","Message":"unauthorized"}]}  (6.1 ms)

It fails a few times, like from 5 to 10 times, and then the next instance of sync-gateway successfully authenticates and performs the things it needs to do...

Is it a known issue? How do I proceed? I can't understand what is happening so I can fix it and then prevent that problem...

Thanks!

Upvotes: 0

Views: 80

Answers (0)

Related Questions