I posted about having Couchbase Client/Bucket initialization problems a few weeks ago using .Net 5 + Couchbase Client 3.1.X, and I thought at the time I had fixed the problem by calling the connection config in a certain way, but actually the problem wasn’t fixed.
Digging deeper on .Net Core 3.1 + the newest Client 3.1.3, I found the following issues:
3.1.X code has this in ConnectionFactory:
//The endpoint we are connecting to
var targetHost = endPoint.Address.ToString();
....
//create the sslstream with appropriate authentication
await sslStream.AuthenticateAsClientAsync(targetHost, certs,
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
_clusterOptions.EnableCertificateRevocation)
.ConfigureAwait(false);
This fails with the following exception:
“Cannot bootstrap bucket [BUCKET] as Couchbase. System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)…”
When comparing to 2.7.X, it seems the problem may lie in using the IP address instead of the hostname in the AuthenticateAsClientAsync call. The 2.7.x code (from SSLConnection) is as follows:
var targetHost = ConnectionPool.Configuration.Uri.Host;
....
_sslStream.AuthenticateAsClientAsync(targetHost,
certs,
SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12,
Configuration.ClientConfiguration.EnableCertificateRevocation).Wait();
- As a temp workaround to see if fixing the above issue would be all that is needed, if I change the Couchbase client code to hardcode the hostname instead of the IP address, or if I utilize the following configs:
opts.KvIgnoreRemoteCertificateNameMismatch = true;
opts.HttpIgnoreRemoteCertificateMismatch = true;
I can get around the auth issue. However in doing so, I encountered another error in ClusterNode where the code never returns on this call from ExecuteOp:
ResponseStatus status;
using (new OperationCancellationRegistration(op, tokenPair))
{
status = await op.Completed.ConfigureAwait(false);
}
This seems to point to 2 issues possibly:
- error in the actual operation
- cancellation doesn’t kick-in (not sure what the timeout is though)
We are on Couchbase 6.0, so I thought it might have to do with the newer ServerFeatures that were introduced in 3.1.x vs 2.7.x. However, commenting them out of the code resulted in the same behaviour.
Any idea how to proceed?