jeudi 4 juin 2015

Amazon Key Service Management encrypt function in PHP

http://ift.tt/1M6PzRs

try {
            $client = KmsClient::factory(array(
                'key'    => 'xxx',
                'secret' => 'xx',
                'region' => 'us-east-1'
            ));

            $result = $client->encrypt(array(
                // KeyId is required
                'KeyId' => 'xxxxx',
                // Plaintext is required
                'Plaintext' => $push_message,
                'EncryptionContext' => array(
                // Associative array of custom 'EncryptionContextKey' key names
                'EncryptionContextKey' => 'loneous',
                ),
                'GrantTokens' => array('test'),
            ));
            echo $result;
        } catch(Exception $ex){
            echo "Exception : ".$ex;
        }

I am new to Amazone KMS (Key Service Management), I have setup console and master key i but I need help in request of encrypt/decrypt method.

What EncryptionContextKey and GrantTokens in this request? What value should i pass here?

Got the exception :-

Exception : exception 'InvalidArgumentException' with message 'Missing required client configuration options: version: (string) A "version" configuration value is required. Specifying a version constraint ensures that your code will not be affected by a breaking change made to the service. For example, when using Amazon S3, you can lock your API version to "2006-03-01". Your build of the SDK has the following version(s) of "kms": * "2014-11-01" You may provide "latest" to the "version" configuration value to utilize the most recent available API version that your client's API provider can find. Note: Using 'latest' in a production application is not recommended. A list of available API versions can be found on each client's API documentation page: http://ift.tt/1trFsBT. If you are unable to load a specific API version, then you may need to update your copy of the SDK.' in /var/www/api/aws/Aws/ClientResolver.php:319 Stack trace: #0 /var/www/api/aws/Aws/ClientResolver.php(215): Aws\ClientResolver->throwRequired(Array) #1 /var/www/api/aws/Aws/AwsClient.php(136): Aws\ClientResolver->resolve(Array, Object(Aws\HandlerList)) #2 /var/www/api/aws/Aws/AwsClient.php(348): Aws\AwsClient->__construct(Array) #3 /var/www/api/kms.php(14): Aws\AwsClient::factory(Array) #4 {main}




Aucun commentaire:

Enregistrer un commentaire