View a markdown version of this page

GetCertificate - AWS Security Token Service

GetCertificate

Returns an X.509 SPIFFE Verifiable Identity Document (X509-SVID) for the workload identity of the calling session. Your workload can use the certificate to prove its identity to peers, for example in mutual TLS (mTLS). The X.509 signer of the workload identity provider that issued the workload identity of the session signs the certificate in the AWS Region that you send the request to.

You can call GetCertificate only with temporary credentials for a role session that has a workload identity, and the workload identity provider must use the SPIFFE naming scheme. You can't call it with long-term IAM user credentials or with federated user credentials from GetFederationToken. AWS STS denies the request if the calling session doesn't have a workload identity. AWS STS also denies the request if the workload identity template or provider of the session no longer exists.

AWS STS takes the identity in the certificate from the calling session, not from the request. AWS STS uses only the public key from the certificate signing request (CSR) that you provide. The certificate chain in the response can include the root certificate authority (CA) certificate, so don't use it as a source of trust anchors. To verify certificates that AWS STS issues, get trust anchors only from GetTrustBundles.

To call GetCertificate, you must have permission for the sts:GetCertificate action. Because AWS STS issues the certificate on your behalf, you must also have permission for the acm-pca:IssueCertificate and acm-pca:GetCertificate actions on the certificate authority (CA) that the signer of the workload identity provider uses.

AWS STS returns some errors from AWS Private CA to you. If AWS Private CA denies the request, the request fails with an access denied error. Check your permissions on the CA. If the account that owns the CA has exceeded its AWS Private CA quota for issuing certificates, the request fails with a throttling error. Check the quotas for AWS Private CA in that account.

Note

The GetCertificate API is not available on the AWS STS global endpoint. Send requests to an AWS STS endpoint in an AWS Region.

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

CertificateSigningRequest

A PEM-encoded PKCS #10 certificate signing request (CSR) that contains the public key for the certificate. The CSR must be signed with the matching private key.

AWS STS uses only the public key from the CSR. AWS STS ignores the subject, subject alternative names (SANs), and requested extensions in the CSR. The signing algorithm of the certificate is set by the signer of the workload identity provider, not by the CSR.

The CSR can be up to 32,768 characters long. If the CSR is blank, can't be parsed, has a signature that doesn't verify, or uses a key type or key size that the signer doesn't support, the request fails with MalformedCertificateSigningRequestException.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 32768.

Pattern: [\u0009\u000A\u000D\u0020-\u00FF]+

Required: Yes

MaxDurationSeconds

The time, in seconds, that the certificate is valid. The value can range from 3,600 seconds (1 hour) to 43,200 seconds (12 hours). If you don't specify a value, the certificate is valid for 43,200 seconds (12 hours).

The expiration of the calling session doesn't limit this value. The certificate can remain valid after the session that requested it expires. This differs from GetWebIdentityToken, which rejects a token duration that ends after the calling session expires.

Type: Integer

Valid Range: Minimum value of 3600. Maximum value of 43200.

Required: No

Response Elements

The following elements are returned by the service.

Certificate

The issued X.509 certificate (X509-SVID), PEM-encoded. The certificate has an empty subject distinguished name (DN) and one URI subject alternative name (SAN) that contains the SPIFFE ID of the workload. You can use the certificate for both client and server authentication.

Type: String

CertificateChain

The PEM-encoded certificate chain that links the certificate to the root certificate authority (CA), in the same format that AWS Private CA returns. The chain can include the root CA certificate. Don't use the chain as a source of trust anchors. To get the trust anchors for the provider, call GetTrustBundles.

Type: String

NotAfter

The date and time, in UTC, when the certificate expires. This is MaxDurationSeconds after AWS STS issued the certificate, or 12 hours if you didn't specify MaxDurationSeconds.

Type: Timestamp

NotBefore

The date and time, in UTC, when the certificate becomes valid. To allow for differences between clocks, AWS STS sets this to five minutes before it issues the certificate.

Type: Timestamp

Subject

The SPIFFE ID of the workload, for example spiffe://example.org/payments/checkout. This is the same value as the URI subject alternative name (SAN) of the certificate, and comes from the calling session.

Type: String

Errors

For information about the errors that are common to all actions, see Common Error Types.

MalformedCertificateSigningRequest

The certificate signing request (CSR) isn't valid. The CSR is blank, isn't a valid PEM-encoded PKCS #10 request, has a signature that doesn't verify, or uses a key type or key size that the signer doesn't support. Correct the CSR and then retry the request.

HTTP Status Code: 400

RegionalSignerUnavailable

The workload identity provider has a signer of the requested type, but no signer in the AWS Region that you sent the request to can sign it right now. This can happen for the following reasons:

  • The signer isn't active yet. A newly added signer doesn't start signing until its scheduled start time. Retry the request after that time.

  • The certificate authority (CA) that the signer uses for GetCertificate can't issue certificates in this Region, for example because you disabled the CA, it expired, or it doesn't exist in this Region. Make sure that the signing CA is active and properly configured, or ask your administrator to check its status.

  • The account that owns the workload identity provider for GetCertificate isn't active. For example, the account is suspended or closed.

HTTP Status Code: 404

SignerNotConfigured

The workload identity provider for the calling session doesn't have a signer for the type of credential that you requested. To call GetCertificate, the provider must have an X.509 signer. To call GetWebIdentityToken with a TokenType of JWT_SVID, the provider must have a JWT signer. Add a signer of that type to the provider, or ask your administrator to add one, and then retry the request.

HTTP Status Code: 404

Examples

Example

This example illustrates one usage of GetCertificate.

Sample Request

aws sts get-certificate \ --certificate-signing-request file://csr.pem \ --max-duration-seconds 3600

Sample Response

{ "Certificate": "-----BEGIN CERTIFICATE-----\nMIICxzCCAk2gAwIBAgIQEXAMPLE...\n-----END CERTIFICATE-----", "CertificateChain": "-----BEGIN CERTIFICATE-----\nMIICIjCCAaigAwIBAgIQEXAMPLE...\n-----END CERTIFICATE-----", "NotBefore": "2026-11-12T16:55:00+00:00", "NotAfter": "2026-11-12T18:00:00+00:00", "Subject": "spiffe://example.org/payments/checkout" }

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: