SSL encryption
PHP Driver supports SSL encryption.
Connecting without SSL encryption
- Given
- a running Cassandra cluster with SSL encryption
- And
- the following example:
$cluster = Dse::cluster()->build(); try { $session = $cluster->connect(); } catch (Dse\Exception\RuntimeException $e) { echo "Connection failure" . PHP_EOL; }
- When
- it is executed
- Then
- its output should contain:
Connection failure
Connecting with basic SSL encryption
- Given
- a running Cassandra cluster with SSL encryption
- And
- the following example:
$ssl = Dse::ssl() ->withVerifyFlags(Dse::VERIFY_NONE) ->build(); $cluster = Dse::cluster() ->withSSL($ssl) ->build(); try { $session = $cluster->connect(); echo "Connection success" . PHP_EOL; } catch (Dse\Exception\RuntimeException $e) { echo "Connection failure" . PHP_EOL; }
- When
- it is executed
- Then
- its output should contain:
Connection success
Connecting with certificate verification
- Given
- a running Cassandra cluster with SSL encryption
- And
- the following example:
$ssl = Dse::ssl() ->withVerifyFlags(Dse::VERIFY_PEER_CERT) ->withTrustedCerts($_SERVER['SERVER_CERT']) ->build(); $cluster = Dse::cluster() ->withSSL($ssl) ->build(); try { $session = $cluster->connect(); echo "Connection success" . PHP_EOL; } catch (Dse\Exception\RuntimeException $e) { echo "Connection failure" . PHP_EOL; }
- When
- it is executed with proper SSL credentials
- Then
- its output should contain:
Connection success
Connecting with client certificate verification
- Given
- a running Cassandra cluster with SSL encryption and client authentication
- And
- the following example:
$ssl = Dse::ssl() ->withVerifyFlags(Dse::VERIFY_PEER_CERT) ->withTrustedCerts($_SERVER['SERVER_CERT']) ->withClientCert($_SERVER['CLIENT_CERT']) ->withPrivateKey($_SERVER['PRIVATE_KEY'], $_SERVER['PASSPHRASE']) ->build(); $cluster = Dse::cluster() ->withSSL($ssl) ->build(); try { $session = $cluster->connect(); echo "Connection success" . PHP_EOL; } catch (Dse\Exception\RuntimeException $e) { echo "Connection failure" . PHP_EOL; }
- When
- it is executed with proper SSL credentials
- Then
- its output should contain:
Connection success