Does Couchbase SDK hostname verification fail when the node certificate SAN omits the bootstrap hostname?
0 reputation · 21 Jan 2024, 08:09 UTC
0 reputation · 21 Jan 2024, 08:09 UTC
Couchbase SDKs use couchbases:// for encrypted connections and validate the server certificate chain and hostname during the TLS handshake. The uncertainty is which hostname the SDK compares against the certificate's Subject Alternative Names (SAN) when the address used for bootstrap differs from the addresses the cluster advertises later.
Several conditions complicate this: DNS SRV bootstrap can return aliases that resolve to node addresses, topology refresh can advertise node hostnames or IP addresses that differ from the bootstrap address, and default self-signed certificates may not list every address in their SAN entries. Trust-store configuration also differs across SDK languages and versions, so verification behavior is not necessarily portable between them.
32775 reputation · 21 Jan 2024, 11:44 UTC
Yes. If you use couchbases://, the Couchbase SDK performs standard TLS hostname verification. If the hostname provided in the connection string (the bootstrap host) is not present in the server certificate's Subject Alternative Names (SAN), the TLS handshake will fail with a hostname mismatch error before the SDK can even begin the bootstrap process.
The SDK performs hostname verification at two distinct stages of the connection lifecycle:
To ensure verification succeeds across all phases, the cluster certificates must contain the following in their SAN entries:
| Connection Stage | Required SAN Entry |
|---|---|
| Bootstrap | The bootstrap hostname/alias used in the connection string. |
| DNS SRV | Any aliases returned by SRV records used for discovery. |
| Topology Refresh | The actual hostnames or IP addresses each node uses to identify itself. |
To diagnose a mismatch, use OpenSSL to check the certificate presented by the bootstrap host:
openssl s_client -connect bootstrap-host:11207 -servername bootstrap-host | openssl x509 -text -noout
Search the output for the Subject Alternative Name section. If the bootstrap-host is missing, the SDK will reject the connection.
This behavior is consistent across major SDK versions (Java, .NET, Node.js), though the specific exception thrown may vary by language. This analysis assumes standard TLS verification; if you have disabled hostname verification in your SDK configuration (not recommended for production), these checks are bypassed.
Missing Diagnostic Detail: Are you using a single global certificate for the cluster or unique certificates per node? If using per-node certificates, the bootstrap alias must be added to every node's certificate to ensure the SDK can bootstrap via any available node.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.