ssl() public static method

Returns SSL Options Builder.
public static ssl ( ) : Cassandra\SSLOptions\Builder
return Cassandra\SSLOptions\Builder an SSLOptions Builder instance
示例#1
0
 public function start()
 {
     $this->run('start', '--wait-other-notice', '--wait-for-binary-proto');
     $builder = Cassandra::cluster()->withPersistentSessions(false)->withContactPoints('127.0.0.1');
     if ($this->ssl || $this->clientAuth) {
         $sslOptions = Cassandra::ssl()->withTrustedCerts(realpath(__DIR__ . '/ssl/cassandra.pem'))->withVerifyFlags(Cassandra::VERIFY_PEER_CERT)->withClientCert(realpath(__DIR__ . '/ssl/driver.pem'))->withPrivateKey(realpath(__DIR__ . '/ssl/driver.key'), 'php-driver')->build();
         $builder->withSSL($sslOptions);
     }
     for ($retries = 1; $retries <= 10; $retries++) {
         try {
             $this->cluster = $builder->build();
             $this->session = $this->cluster->connect();
             break;
         } catch (Cassandra\Exception\RuntimeException $e) {
             unset($this->session);
             unset($this->cluster);
             sleep($retries * 0.4);
         }
     }
     if (!isset($this->session)) {
         throw new RuntimeException("Unable to initialize a Session, check cassandra logs");
     }
 }
 /**
  * Initialize the SQL datastore.
  */
 protected function __construct()
 {
     $config = SimpleSAML_Configuration::getInstance();
     $keyspace = $config->getString('store.cassandra.keyspace');
     $nodes = $config->getArrayize('store.cassandra.nodes');
     $use_ssl = $config->getBoolean('store.cassandra.use_ssl', false);
     $ssl_ca = $config->getString('store.cassandra.ssl_ca', null);
     $username = $config->getString('store.cassandra.username', null);
     $password = $config->getString('store.cassandra.password', null);
     $cluster = \Cassandra::cluster()->withContactPoints(implode(',', $nodes))->withDefaultConsistency(\Cassandra::CONSISTENCY_LOCAL_QUORUM);
     if (isset($username) && isset($password)) {
         $cluster = $cluster->withCredentials($username, $password);
     }
     if ($use_ssl) {
         $ssl = \Cassandra::ssl()->withVerifyFlags(\Cassandra::VERIFY_PEER_CERT);
         if ($ssl_ca) {
             $ssl = $ssl->withTrustedCerts($ssl_ca);
         }
         $ssl = $ssl->build();
         $cluster = $cluster->withSSL($ssl);
     }
     $cluster = $cluster->build();
     $this->db = $cluster->connect($keyspace);
 }