Triage and Remediation
Check Cause
Using Console
Using Console
- Sign in to the AWS Management Console and open the API Gateway console at https://console.aws.amazon.com/apigateway/.
- In the navigation pane, choose ‘APIs’.
- In the APIs pane, choose the API you want to check.
- In the API details pane, choose ‘Client Certificates’.
- In the Client Certificates pane, you can see the expiration date of the SSL client certificate. If the certificate is about to expire, it indicates a misconfiguration.
Using CLI
Using CLI
- First, you need to install and configure AWS CLI on your local machine. You can do this by following the instructions provided by AWS. Make sure you have the necessary permissions to access the API Gateway.
-
Once the AWS CLI is installed and configured, you can use the following command to list all the APIs in your AWS account:
This command will return a list of all the APIs in your account. Note down the id of the API you want to check.
-
Now, you can use the following command to get the details of the API:
Replace
<your-api-id>
with the id of your API. This command will return the details of the API including the client certificate id if one is associated with the API. -
Finally, you can use the following command to get the details of the client certificate:
Replace
<your-client-certificate-id>
with the id of your client certificate. This command will return the details of the client certificate including the expiration date. You can then check if the certificate is about to expire.
Using Python
Using Python
-
Setup AWS SDK (Boto3) in Python:
First, you need to set up AWS SDK (Boto3) in your Python environment. You can install it using pip:
Then, configure your AWS credentials either by setting up environment variables or by using the AWS CLI.
-
List all the API Gateways:
Use the
get_rest_apis
function from theapigateway
client in Boto3 to list all the API Gateways in your AWS account. Here is a sample script:This script will print the name and ID of all the API Gateways. -
Get the Client Certificate of each API Gateway:
Use the
get_client_certificate
function from theapigateway
client in Boto3 to get the details of the client certificate of each API Gateway. Here is a sample script:This script will print the details of the client certificate of each API Gateway. -
Check the Expiration Date of the Client Certificate:
The
get_client_certificate
function returns a dictionary that includes theexpirationDate
of the client certificate. You can compare this date with the current date to check if the certificate is expiring soon. Here is a sample script:This script will print a warning message for each API Gateway whose client certificate is expiring in less than 30 days.