| 
17 | 17 | 
 
  | 
18 | 18 | namespace OpenCloud\Database;  | 
19 | 19 | 
 
  | 
 | 20 | +use Guzzle\Http\ClientInterface;  | 
20 | 21 | use OpenCloud\Common\Service\NovaService;  | 
21 | 22 | use OpenCloud\Database\Resource\Instance;  | 
22 | 23 | use OpenCloud\Database\Resource\Configuration;  | 
@@ -104,4 +105,39 @@ public function datastoreList($params = array())  | 
104 | 105 | 
 
  | 
105 | 106 |         return $this->resourceList('Datastore', $url);  | 
106 | 107 |     }  | 
 | 108 | + | 
 | 109 | +    /**  | 
 | 110 | +     * {@inheritDoc}  | 
 | 111 | +     */  | 
 | 112 | +    public function setClient(ClientInterface $client)  | 
 | 113 | +    {  | 
 | 114 | +        // The Rackspace Cloud Databases service only supports the  | 
 | 115 | +        // RC4 SSL cipher which is not supported by modern OpenSSL clients.  | 
 | 116 | +        // Until the service can support additional, more modern and secure  | 
 | 117 | +        // ciphers, this SDK has to ask curl to allow using the weaker  | 
 | 118 | +        // cipher. For more information, see https://github.com/rackspace/php-opencloud/issues/560  | 
 | 119 | + | 
 | 120 | +        $curlOptions = $client->getConfig()->get('curl.options');  | 
 | 121 | +        $curlOptions['CURLOPT_SSL_CIPHER_LIST'] = static::getSslCipherList();  | 
 | 122 | +        $client->getConfig()->set('curl.options', $curlOptions);  | 
 | 123 | + | 
 | 124 | +        $logMessage = 'The SDK is using a custom cipher suite when connecting '  | 
 | 125 | +                    . 'to the Rackspace Cloud Databases service. This suite contains '  | 
 | 126 | +                    . 'a weak cipher (RC4) so please use at your own risk. See '  | 
 | 127 | +                    . 'https://github.com/rackspace/php-opencloud/issues/560 for details.';  | 
 | 128 | +        $client->getLogger()->critical($logMessage);  | 
 | 129 | + | 
 | 130 | +        $this->client = $client;  | 
 | 131 | +    }  | 
 | 132 | + | 
 | 133 | +    /**  | 
 | 134 | +     * @see https://github.com/rackspace/php-opencloud/issues/560#issuecomment-81790778  | 
 | 135 | +     */  | 
 | 136 | +    public static function getSslCipherList()  | 
 | 137 | +    {  | 
 | 138 | +        return 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:'  | 
 | 139 | +            . 'ECDH+AES128:DH+AES:ECDH+HIGH:DH+HIGH:ECDH+3DES:'  | 
 | 140 | +            . 'DH+3DES:RSA+AESGCM:RSA+AES:RSA+HIGH:RSA+3DES:'  | 
 | 141 | +            . 'ECDH+RC4:DH+RC4:RSA+RC4:!aNULL:!eNULL:!MD5';  | 
 | 142 | +    }  | 
107 | 143 | }  | 
0 commit comments