Skip to content

Commit 7169a57

Browse files
authored
Deprecate cass_cluster_set_use_hostname_resolution() (#523)
Deprecate the function and update docs accordingly
1 parent 90df2c9 commit 7169a57

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

include/cassandra.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -2565,8 +2565,8 @@ cass_cluster_set_use_schema(CassCluster* cluster,
25652565
/**
25662566
* Enable/Disable retrieving hostnames for IP addresses using reverse IP lookup.
25672567
*
2568-
* This is useful for authentication (Kerberos) or encryption (SSL) services
2569-
* that require a valid hostname for verification.
2568+
* @deprecated Do not use. Using reverse DNS lookup to verify the certificate
2569+
* does not protect against man-in-the-middle attacks.
25702570
*
25712571
* <b>Default:</b> cass_false (disabled).
25722572
*
@@ -2578,9 +2578,9 @@ cass_cluster_set_use_schema(CassCluster* cluster,
25782578
*
25792579
* @see cass_cluster_set_resolve_timeout()
25802580
*/
2581-
CASS_EXPORT CassError
2581+
CASS_EXPORT CASS_DEPRECATED(CassError
25822582
cass_cluster_set_use_hostname_resolution(CassCluster* cluster,
2583-
cass_bool_t enabled);
2583+
cass_bool_t enabled));
25842584

25852585
/**
25862586
* Enable/Disable the randomization of the contact points list.
@@ -4598,9 +4598,9 @@ cass_ssl_add_trusted_cert_n(CassSsl* ssl,
45984598
* CASS_SSL_VERIFY_PEER_IDENTITY - IP address matches the certificate's
45994599
* common name or one of its subject alternative names. This implies the
46004600
* certificate is also present.
4601-
* CASS_SSL_VERIFY_PEER_IDENTITY_DNS - Hostname matches the certificate's
4602-
* common name or one of its subject alternative names. This implies the
4603-
* certificate is also present. Hostname resolution must also be enabled.
4601+
* CASS_SSL_VERIFY_PEER_IDENTITY_DNS - Do not use. This option requires the
4602+
* use of reverse DNS lookup which is not sufficient to protect against
4603+
* man-in-the-middle attacks.
46044604
*
46054605
* <b>Default:</b> CASS_SSL_VERIFY_PEER_CERT
46064606
*
@@ -4610,7 +4610,6 @@ cass_ssl_add_trusted_cert_n(CassSsl* ssl,
46104610
* @param[in] flags
46114611
* @return CASS_OK if successful, otherwise an error occurred
46124612
*
4613-
* @see cass_cluster_set_use_hostname_resolution()
46144613
*/
46154614
CASS_EXPORT void
46164615
cass_ssl_set_verify_flags(CassSsl* ssl,

topics/security/ssl/README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -172,24 +172,28 @@ If a unique certificate has been generated for each Cassandra node with the IP a
172172
**NOTE:** This is disabled by default.
173173

174174
```c
175-
CassSsl* ssl = cass_ssl_new();
176-
177175
// Add identity verification flag: CASS_SSL_VERIFY_PEER_IDENTITY (IP address)
178176
cass_ssl_set_verify_flags(ssl, CASS_SSL_VERIFY_PEER_CERT | CASS_SSL_VERIFY_PEER_IDENTITY);
179177

180-
// Or use: CASS_SSL_VERIFY_PEER_IDENTITY_DNS (domain name)
181-
cass_ssl_set_verify_flags(ssl, CASS_SSL_VERIFY_PEER_CERT | CASS_SSL_VERIFY_PEER_IDENTITY_DNS);
182178
```
183179
184-
If using a domain name to verify the peer's identity then hostname resolution
185-
(reverse DNS) needs to be enabled:
186-
187-
**NOTE:** This is also disabled by default.
180+
**Important:** Previous versions of this section suggested using reverse DNS lookup as a way to validate the peer's certificate i.e. using `CASS_SSL_VERIFY_PEER_IDENTITY_DNS` with `cass_cluster_set_use_hostname_resolution(cluster, cass_true)`, but this is susceptible to man-in-the-middle (MITM) attacks and is no longer recommended.
188181
189182
```c
183+
/* DO NOT USE THE FOLLOWING. IT IS SUSCEPTIBLE TO MITM ATTACKS: */
184+
185+
CassSsl* ssl = cass_ssl_new();
186+
187+
cass_ssl_set_verify_flags(ssl, CASS_SSL_VERIFY_PEER_CERT | CASS_SSL_VERIFY_PEER_IDENTITY_DNS);
188+
189+
/* ... */
190+
190191
CassCluster* cluster = cass_cluster_new();
191192
192-
// Enable reverse DNS
193+
/*
194+
This can allow an attacker to use their own certificate to fool the driver into thinking it's
195+
connected to the intended endpoint, but is instead connected to the attacker's endpoint.
196+
*/
193197
cass_cluster_set_use_hostname_resolution(cluster, cass_true);
194198
195199
/* ... */

0 commit comments

Comments
 (0)