upload_server_certificate ( $server_certificate_name, $certificate_body, $private_key, $opt )

Uploads a server certificate entity for the AWS account. The server certificate entity includes a public key certificate, a private key, and an optional certificate chain, which should all be PEM-encoded.

For information about the number of server certificates you can upload, see Limitations on IAM Entities in Using AWS Identity and Access Management.

Because the body of the public key certificate, private key, and the certificate chain can be large, you should use POST rather than GET when calling UploadServerCertificate. For information about setting up signatures and authorization through the API, go to Signing AWS API Requests in the AWS General Reference. For general information about using the Query API with IAM, go to Making Query Requests in Using IAM.

Access

public

Parameters

Parameter

Type

Required

Description

$server_certificate_name

string

Required

The name for the server certificate. Do not include the path in this value. [Constraints: The value must be between 1 and 128 characters, and must match the following regular expression pattern: [\w+=,.@-]*]

$certificate_body

string

Required

The contents of the public key certificate in PEM-encoded format. [Constraints: The value must be between 1 and 16384 characters, and must match the following regular expression pattern: [\u0009\u000A\u000D\u0020-\u00FF]+]

$private_key

string

Required

The contents of the private key in PEM-encoded format. [Constraints: The value must be between 1 and 16384 characters, and must match the following regular expression pattern: [\u0009\u000A\u000D\u0020-\u00FF]*]

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • Path - string - Optional - The path for the server certificate. For more information about paths, see Identifiers for IAM Entities in Using AWS Identity and Access Management. This parameter is optional. If it is not included, it defaults to a slash (/). [Constraints: The value must be between 1 and 512 characters, and must match the following regular expression pattern: (\u002F)|(\u002F[\u0021-\u007F]+\u002F)]
  • CertificateChain - string - Optional - The contents of the certificate chain. This is typically a concatenation of the PEM-encoded public key certificates of the chain. [Constraints: The value must be between 1 and 2097152 characters, and must match the following regular expression pattern: [\u0009\u000A\u000D\u0020-\u00FF]*]
  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Upload a server certificate.

$certificate_body = <<<CERT
-----BEGIN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NizI8fApMQppcTfJj4iYpaD0KKPRQpyLAttT/V9jmcWbpULWEXAMPLEJ92ZBxYf
EXAMPLEmTuL784RKKxOSnKKWj4M5an7xSf1tA5mV6okFDyyN0lCsmKL0c03E
-----END EXAMPLE CERTIFICATE-----
CERT;

$private_key = <<<CERT
-----BEGIN EXAMPLE PRIVATE KEY-----
EXAMPLEBAAKBgQDjkB/FCpalkBIreo1mDxbOcN1CXGyULCu3V8pftj7oPoUq6qXj
FxE9ASQEXAMPLEPxFUyFFsgYPZ4s7s7j4VavsufFdWD3OXJp0z1p53KGOpE0U1P1
K+u2N5GJzWFnkHEXAMPLEwX34KkDT9z0iEXZx7kJqRt4EEJfm10EBBwq/QIDAQAB
AoGBAJQkNwpnIjsV1z5GwEXAMPLEL6IL2QN83di1ZiF42usGCFsv9l4nnilAnOKi
7VWyxQgk/XOGqSxesKI/tJ/VCkCMEXAMPLEp7CQQYDELtUEDadJ77w+ZemNKScDD
CXlIZ1z1W739tYYgNTZ8HLA7w0uVrfZHoMZEXAMPLEPSLLlhAkEA/8NnI6Set64T
DsH0byUQv/O6VgQvBvoogYlb60/C7DWn4WC2PgNiOfEXAMPLELci27nriuWxOtWR
dLhN8wSQIwJBAOPGCjEToxmhsV69Bb5ZYiE3b0xdAGquFKrdcEXAMPLENRJ/IkNU
pY26F8GZdyZl0eTJbTGDUCitCp2hKSL+el8CQG2MndXXgiA80G7mxrMAEXAMPLE+
EXAMPLEFkfiVfnE8fj779LNVMbKUGsOUE7Z7QtQIq4of3izMI3RyKPkpgC8CQQDE
6wsWoMaEXAMPLEVOmpIW64kieOkKUdP2YJlFwiAjcICgrB8gHMdAP1mYe6giHzcW
V/o6Ky+a6vdZjeEXAMPLEkEArbLU9LfQmAq33t1K1Pv9Yq78sqwLpwR7gDhwGPGd
US3NZ8NTQUlWVi4QB7qoLEXAMPLEBaqFIyh83FIYqP/eYQ==
-----END EXAMPLE PRIVATE KEY-----
CERT;

// Instantiate the class
$iam = new AmazonIAM();

$response = $iam->upload_server_certificate('my-server-cert', $certificate_body, $private_key, array(
	'Path' => '/mycerts/'
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Source

Method defined in services/iam.class.php | Toggle source view (9 lines) | View on GitHub

public function upload_server_certificate($server_certificate_name, $certificate_body, $private_key, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['ServerCertificateName'] = $server_certificate_name;
    $opt['CertificateBody'] = $certificate_body;
    $opt['PrivateKey'] = $private_key;
    
    return $this->authenticate('UploadServerCertificate', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback