ACM を使用した の例 AWS SDK for .NET - AWS SDK for .NET

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

ACM を使用した の例 AWS SDK for .NET

次のコード例は、 AWS SDK for .NET で を使用してアクションを実行し、一般的なシナリオを実装する方法を示していますACM。

アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には、完全なソースコードへのリンクが含まれています。このリンクには、コンテキスト内でコードをセットアップして実行する方法の手順が記載されています。

トピック

アクション

次の例は、DescribeCertificate を使用する方法を説明しています。

AWS SDK for .NET
注記

については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

using System; using System.Threading.Tasks; using Amazon; using Amazon.CertificateManager; using Amazon.CertificateManager.Model; namespace DescribeCertificate { class DescribeCertificate { // The following example retrieves and displays the metadata for a // certificate using the AWS Certificate Manager (ACM) service. // 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 Amazon.CertificateManager.AmazonCertificateManagerClient(ACMRegion); var describeCertificateReq = new DescribeCertificateRequest(); // The ARN used here is just an example. Replace it with the ARN of // a certificate that exists on your account. describeCertificateReq.CertificateArn = "arn:aws:acm:us-east-1:123456789012:certificate/8cfd7dae-9b6a-2d07-92bc-1c309EXAMPLE"; var certificateDetailResp = DescribeCertificateResponseAsync(client: _client, request: describeCertificateReq); var certificateDetail = certificateDetailResp.Result.Certificate; if (certificateDetail is not null) { DisplayCertificateDetails(certificateDetail); } } /// <summary> /// Displays detailed metadata about a certificate retrieved /// using the ACM service. /// </summary> /// <param name="certificateDetail">The object that contains details /// returned from the call to DescribeCertificateAsync.</param> static void DisplayCertificateDetails(CertificateDetail certificateDetail) { Console.WriteLine("\nCertificate Details: "); Console.WriteLine($"Certificate Domain: {certificateDetail.DomainName}"); Console.WriteLine($"Certificate Arn: {certificateDetail.CertificateArn}"); Console.WriteLine($"Certificate Subject: {certificateDetail.Subject}"); Console.WriteLine($"Certificate Status: {certificateDetail.Status}"); foreach (var san in certificateDetail.SubjectAlternativeNames) { Console.WriteLine($"Certificate SubjectAlternativeName: {san}"); } } /// <summary> /// Retrieves the metadata associated with the ACM service certificate. /// </summary> /// <param name="client">An AmazonCertificateManagerClient object /// used to call DescribeCertificateResponse.</param> /// <param name="request">The DescribeCertificateRequest object that /// will be passed to the method call.</param> /// <returns></returns> static async Task<DescribeCertificateResponse> DescribeCertificateResponseAsync( AmazonCertificateManagerClient client, DescribeCertificateRequest request) { var response = new DescribeCertificateResponse(); try { response = await client.DescribeCertificateAsync(request); } catch (InvalidArnException) { Console.WriteLine($"Error: The ARN specified is invalid."); } catch (ResourceNotFoundException) { Console.WriteLine($"Error: The specified certificate could not be found."); } return response; } } }
  • API 詳細については、「 リファレンスDescribeCertificate」の「」を参照してください。 AWS SDK for .NET API

次の例は、ListCertificates を使用する方法を説明しています。

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