

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# DeleteCertificateAuthority
<a name="JavaApi-DeleteCertificateAuthority"></a>

다음 Java 샘플은 [DeleteCertificateAuthority](https://docs.aws.amazon.com/privateca/latest/APIReference/API_DeleteCertificateAuthority.html) 작업을 사용하는 방법을 보여줍니다.

이 작업은 [CreateCertificateAuthority](https://docs.aws.amazon.com/privateca/latest/APIReference/API_CreateCertificateAuthority.html) 작업을 사용하여 생성한 사설 CA(인증 기관)를 삭제합니다. `DeleteCertificateAuthority` 작업을 수행하려면 삭제할 CA의 ARN을 제공해야 합니다. [ListCertificateAuthorities](https://docs.aws.amazon.com/privateca/latest/APIReference/API_ListCertificateAuthorities.html) 작업을 호출하여 ARN을 찾을 수 있습니다. 상태가 `CREATING` 또는 `PENDING_CERTIFICATE`인 경우 프라이빗 CA를 즉시 삭제할 수 있습니다. 하지만 이미 인증서를 가져온 경우에는 즉시 삭제할 수 없습니다. 먼저 [UpdateCertificateAuthority](https://docs.aws.amazon.com/privateca/latest/APIReference/API_UpdateCertificateAuthority.html) 작업을 호출하여 CA를 비활성화하고 `Status` 파라미터를 `DISABLED`로 설정해야 합니다. 그런 다음 `DeleteCertificateAuthority` 작업에서 `PermanentDeletionTimeInDays` 파라미터를 사용하여 7 \~ 30까지 일 수를 지정할 수 있습니다. 이 기간 동안 사설 CA를 `disabled` 상태로 복원할 수 있습니다. 기본적으로 `PermanentDeletionTimeInDays` 파라미터를 설정하지 않은 경우 복원 기간은 30일입니다. 이 기간이 만료되면 프라이빗 CA가 영구적으로 삭제되며 복원할 수 없습니다. 자세한 내용은 [CA 복원](PCARestoreCA.md) 단원을 참조하십시오.

[RestoreCertificateAuthority](https://docs.aws.amazon.com/privateca/latest/APIReference/API_RestoreCertificateAuthority.html) 작업을 사용하는 방법을 보여주는 Java 예제는 [RestoreCertificateAuthority](JavaApi-RestoreCertificateAuthority.md) 섹션을 참조하세요.

```
package com.amazonaws.samples;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
import com.amazonaws.client.builder.AwsClientBuilder;
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
import com.amazonaws.auth.AWSStaticCredentialsProvider;

import com.amazonaws.services.acmpca.AWSACMPCA;
import com.amazonaws.services.acmpca.AWSACMPCAClientBuilder;

import com.amazonaws.services.acmpca.model.DeleteCertificateAuthorityRequest;

import com.amazonaws.AmazonClientException;
import com.amazonaws.services.acmpca.model.ResourceNotFoundException;
import com.amazonaws.services.acmpca.model.InvalidArnException;
import com.amazonaws.services.acmpca.model.InvalidStateException;
import com.amazonaws.services.acmpca.model.RequestFailedException;

public class DeleteCertificateAuthority {

   public static void main(String[] args) throws Exception{

      // Retrieve your credentials from the C:\Users\name\.aws\credentials file
      // in Windows or the .aws/credentials file in Linux.
      AWSCredentials credentials = null;
      try {
         credentials = new ProfileCredentialsProvider("default").getCredentials();
      } catch (Exception e) {
         throw new AmazonClientException("Cannot load your credentials from disk", e);
      }

      // Define the endpoint for your sample.
      String endpointRegion = "{{region}}";  // Substitute your region here, e.g. "us-west-2"
      String endpointProtocol = "https://acm-pca." + endpointRegion + ".amazonaws.com/";
      EndpointConfiguration endpoint =
            new AwsClientBuilder.EndpointConfiguration(endpointProtocol, endpointRegion);

      // Create a client that you can use to make requests.
      AWSACMPCA client = AWSACMPCAClientBuilder.standard()
         .withEndpointConfiguration(endpoint)
         .withCredentials(new AWSStaticCredentialsProvider(credentials))
         .build();

      // Create a requrest object and set the ARN of the private CA to delete.
      DeleteCertificateAuthorityRequest req = new DeleteCertificateAuthorityRequest();

      // Set the certificate authority ARN.
      req.withCertificateAuthorityArn("arn:{{aws}}:acm-pca:{{us-east-1}}:{{111122223333}}:certificate-authority/{{11223344-1234-1122-2233-112233445566}}");
            
      // Set the recovery period.
      req.withPermanentDeletionTimeInDays(12);            

      // Delete the CA.
      try {
         client.deleteCertificateAuthority(req);
      } catch (ResourceNotFoundException ex) {
         throw ex;
      } catch (InvalidArnException ex) {
         throw ex;
      } catch (InvalidStateException ex) {
         throw ex;
      } catch (RequestFailedException ex) {
         throw ex;
      }
   }
}
```