または ListCertificatesAWS SDKで を使用する CLI - AWS SDK CLI コードの例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

または ListCertificatesAWS SDKで を使用する CLI

以下のコード例は、ListCertificates の使用方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

.NET
AWS SDK for .NET
注記

については、「」を参照してください GitHub。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。

using System; using System.Threading.Tasks; using Amazon; using Amazon.CertificateManager; using Amazon.CertificateManager.Model; namespace ListCertificates { // The following example retrieves and displays a list of the // certificates defined for the default account using the AWS // Certificate Manager (ACM) service. class ListCertificates { // Specify your AWS Region (an example Region is shown). private static readonly RegionEndpoint ACMRegion = RegionEndpoint.USEast1; private static AmazonCertificateManagerClient _client; static void Main(string[] args) { _client = new AmazonCertificateManagerClient(ACMRegion); var certificateList = ListCertificatesResponseAsync(client: _client); Console.WriteLine("Certificate Summary List\n"); foreach (var certificate in certificateList.Result.CertificateSummaryList) { Console.WriteLine($"Certificate Domain: {certificate.DomainName}"); Console.WriteLine($"Certificate ARN: {certificate.CertificateArn}\n"); } } /// <summary> /// Retrieves a list of the certificates defined in this Region. /// </summary> /// <param name="client">The ACM client object passed to the /// ListCertificateResAsync method call.</param> /// <param name="request"></param> /// <returns>The ListCertificatesResponse.</returns> static async Task<ListCertificatesResponse> ListCertificatesResponseAsync( AmazonCertificateManagerClient client) { var request = new ListCertificatesRequest(); var response = await client.ListCertificatesAsync(request); return response; } } }
  • API 詳細については、「 リファレンスListCertificates」の「」を参照してください。 AWS SDK for .NET API

C++
SDK C++ 用
注記

については、「」を参照してください GitHub。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。

//! List the AWS Certificate Manager (ACM) certificates in an account. /*! \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::ACM::listCertificates( const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::ACM::ACMClient acmClient(clientConfiguration); Aws::ACM::Model::ListCertificatesRequest request; Aws::Vector<Aws::ACM::Model::CertificateSummary> allCertificates; Aws::String nextToken; do { if (!nextToken.empty()) { request.SetNextToken(nextToken); } Aws::ACM::Model::ListCertificatesOutcome outcome = acmClient.ListCertificates(request); if (!outcome.IsSuccess()) { std::cerr << "Error: ListCertificates: " << outcome.GetError().GetMessage() << std::endl; return false; } else { const Aws::ACM::Model::ListCertificatesResult &result = outcome.GetResult(); const Aws::Vector<Aws::ACM::Model::CertificateSummary> &certificates = result.GetCertificateSummaryList(); allCertificates.insert(allCertificates.end(), certificates.begin(), certificates.end()); nextToken = result.GetNextToken(); } } while (!nextToken.empty()); if (!allCertificates.empty()) { for (const Aws::ACM::Model::CertificateSummary &certificate: allCertificates) { std::cout << "Certificate ARN: " << certificate.GetCertificateArn() << std::endl; std::cout << "Domain name: " << certificate.GetDomainName() << std::endl << std::endl; } } else { std::cout << "No available certificates found in account." << std::endl; } return true; }
  • API 詳細については、「 リファレンスListCertificates」の「」を参照してください。 AWS SDK for C++ API

CLI
AWS CLI

AWS アカウントのACM証明書を一覧表示するには

次のlist-certificatesコマンドは、アカウント内の証明書ARNsの を一覧表示します。

aws acm list-certificates

このコマンドを処理すると、次のような出力が生成されます。

{ "CertificateSummaryList": [ { "CertificateArn": "arn:aws:acm:region:account:certificate/12345678-1234-1234-1234-123456789012", "DomainName": "www.example.com" }, { "CertificateArn": "arn:aws:acm:region:account:certificate/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "DomainName": "www.example.net" } ] }

list-certificates を呼び出すたびに表示される証明書の数を指定できます。例えば、証明書が 4 つあって一度に 2 つまでを表示する場合は、次の例のように max-items 引数を 2 に設定します。

aws acm list-certificates --max-items 2

2 つの証明書ARNsとNextToken値が表示されます。

"CertificateSummaryList": [ { "CertificateArn": "arn:aws:acm:region:account: \ certificate/12345678-1234-1234-1234-123456789012", "DomainName": "www.example.com" }, { "CertificateArn": "arn:aws:acm:region:account: \ certificate/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "DomainName": "www.example.net" } ], "NextToken": "9f4d9f69-275a-41fe-b58e-2b837bd9ba48"

アカウント内の次の 2 つの証明書を表示するには、次の呼び出しで NextToken 値を設定します。

aws acm list-certificates --max-items 2 --next-token 9f4d9f69-275a-41fe-b58e-2b837bd9ba48

certificate-statuses 引数を使用して出力をフィルタリングできます。次のコマンドは、PENDING_VALIDATION ステータスの証明書を表示します。

aws acm list-certificates --certificate-statuses PENDING_VALIDATION

また、includes 引数を使用して出力をフィルタリングすることもできます。次のコマンドは、以下のプロパティでフィルタリングされた証明書を表示します。表示される証明書:

- Specify that the RSA algorithm and a 2048 bit key are used to generate key pairs. - Contain a Key Usage extension that specifies that the certificates can be used to create digital signatures. - Contain an Extended Key Usage extension that specifies that the certificates can be used for code signing. aws acm list-certificates --max-items 10 --includes extendedKeyUsage=CODE_SIGNING,keyUsage=DIGITAL_SIGNATURE,keyTypes=RSA_2048
  • API 詳細については、「 コマンドリファレンスListCertificates」の「」を参照してください。 AWS CLI

PowerShell
のツール PowerShell

例 1: すべての証明書ARNsとそれぞれのドメイン名のリストを取得します。コマンドレットは自動的にページ分割され、すべての を取得しますARNs。ページ分割を手動で制御するには、- MaxItem パラメータを使用して各サービス呼び出しに対して返ARNsされる証明書の数を制御し、- NextToken パラメータを使用して各呼び出しの開始点を示します。

Get-ACMCertificateList

出力:

CertificateArn DomainName -------------- ---------- arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012 www.example.com

例 2: 指定された状態で証明書ステータスARNsが一致するすべての証明書のリストを取得します。

Get-ACMCertificateList -CertificateStatus "VALIDATION_TIMED_OUT","FAILED"

例 3: この例では、キータイプが RSA_2048、拡張キーの使用法または目的が CODE_ である us-east-1 リージョン内のすべての証明書のリストを返しますSIGNING。これらのフィルタリングパラメータの値は、 ListCertificates 「フィルターAPIリファレンス」トピックで確認できます https://docs.aws.amazon.com/acm/latest/APIReference/API_Filters.html。

Get-ACMCertificateList -Region us-east-1 -Includes_KeyType RSA_2048 -Includes_ExtendedKeyUsage CODE_SIGNING

出力:

CertificateArn DomainName -------------- ---------- arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-d7c0-48c1-af8d-2133d8f30zzz *.route53docs.com arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-98a5-443d-a734-800430c80zzz nerdzizm.net arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-2be6-4376-8fa7-bad559525zzz arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-e7ca-44c5-803e-24d9f2f36zzz arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-1241-4b71-80b1-090305a62zzz arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-8709-4568-8c64-f94617c99zzz arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-a8fa-4a61-98cf-e08ccc0eezzz arn:aws:acm:us-east-1:8xxxxxxxxxxx:certificate/xxxxxxxx-fa47-40fe-a714-2d277d3eezzz *.route53docs.com
  • API 詳細については、「 コマンドレットリファレンスListCertificates」の「」を参照してください。 AWS Tools for PowerShell

Python
SDK for Python (Boto3)
注記

については、「」を参照してください GitHub。AWS コード例リポジトリ で全く同じ例を見つけて、設定と実行の方法を確認してください。

class AcmCertificate: """ Encapsulates ACM functions. """ def __init__(self, acm_client): """ :param acm_client: A Boto3 ACM client. """ self.acm_client = acm_client def list( self, max_items, statuses=None, key_usage=None, extended_key_usage=None, key_types=None, ): """ Lists the certificates for the current account. :param max_items: The maximum number of certificates to list. :param statuses: Filters the results to the specified statuses. If None, all certificates are included. :param key_usage: Filters the results to the specified key usages. If None, all key usages are included. :param extended_key_usage: Filters the results to the specified extended key usages. If None, all extended key usages are included. :param key_types: Filters the results to the specified key types. If None, all key types are included. :return: The list of certificates. """ try: kwargs = {"MaxItems": max_items} if statuses is not None: kwargs["CertificateStatuses"] = statuses includes = {} if key_usage is not None: includes["keyUsage"] = key_usage if extended_key_usage is not None: includes["extendedKeyUsage"] = extended_key_usage if key_types is not None: includes["keyTypes"] = key_types if includes: kwargs["Includes"] = includes response = self.acm_client.list_certificates(**kwargs) certificates = response["CertificateSummaryList"] logger.info("Got %s certificates.", len(certificates)) except ClientError: logger.exception("Couldn't get certificates.") raise else: return certificates
  • API 詳細については、「 for Python (Boto3) リファレンスListCertificates」の「」を参照してください。 AWS SDK API