Working with IAM Server Certificates

To enable HTTPS connections to your website or application on AWS, you need an SSL/TLS server certificate. To use a certificate that you obtained from an external provider with your website or application on AWS, you must upload the certificate to IAM or import it into AWS Certificate Manager.

The examples below show how to:

All the example code for the AWS SDK for PHP is available here on GitHub.

Credentials

Before running the example code, configure your AWS credentials, as described in Credentials.

List Server Certificates

require 'vendor/autoload.php';
use Aws\Iam\IamClient;
use Aws\Exception\AwsException;

$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);
try {
    $result = $client->listServerCertificates();
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}

Retrieve a Server Certificate

require 'vendor/autoload.php';
use Aws\Iam\IamClient;
use Aws\Exception\AwsException;

$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);
try {
    $result = $client->getServerCertificate(array(
        // ServerCertificateName is required
        'ServerCertificateName' => 'string',
    ));
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}

Update a Server Certificate

require 'vendor/autoload.php';
use Aws\Iam\IamClient;
use Aws\Exception\AwsException;

$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);
try {
    $result = $client->updateServerCertificate(array(
        // ServerCertificateName is required
        'ServerCertificateName' => 'string',
        'NewServerCertificateName' => 'string',
    ));
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}

Delete a Server Certificate

require 'vendor/autoload.php';
use Aws\Iam\IamClient;
use Aws\Exception\AwsException;

$client = new IamClient([
    'profile' => 'default',
    'region' => 'us-west-2',
    'version' => '2010-05-08'
]);
try {
    $result = $client->deleteServerCertificate(array(
        // ServerCertificateName is required
        'ServerCertificateName' => 'string',
    ));
    var_dump($result);
} catch (AwsException $e) {
    // output error message if fails
    error_log($e->getMessage());
}