인증 기관 삭제

Certificate Authority Service를 사용하면 기존 인증 기관(CA)을 삭제할 수 있습니다. CA는 삭제 프로세스가 시작되고 유예 기간 30일이 지난 후에 영구적으로 삭제됩니다. 유예 기간이 지나면 CA Service는 CA 및 인증서, 해지 인증서 목록(CRL) 등의 모든 중첩된 아티팩트를 영구적으로 삭제합니다.

Cloud Storage 버킷 또는 Cloud Key Management Service 키와 같이 삭제된 CA에서 사용 중이던 고객 관리 Google Cloud 리소스는 삭제되지 않습니다. Google 관리 및 고객 관리 리소스에 대한 자세한 내용은 리소스 관리를 참조하세요.

유예 기간 중에는 삭제된 CA에 대한 요금이 청구되지 않습니다. 하지만 CA를 복원하면 CA가 DELETED 상태였던 기간에 대해 CA의 결제 등급을 기준으로 요금이 청구됩니다.

시작하기 전에

  • CA Service 작업 관리자(roles/privateca.caManager) 또는 CA Service 관리자(roles/privateca.admin) Identity and Access Management (IAM) 역할이 있는지 확인합니다. CA Service의 사전 정의된 IAM 역할에 대한 자세한 내용은 IAM으로 액세스 제어를 참조하세요.

    IAM 역할 부여에 대한 자세한 내용은 단일 역할 부여를 참조하세요.

  • CA가 다음 조건을 충족하는지 확인합니다.

    • CA가 AWAITING_USER_ACTIVATION, DISABLED 또는 STAGED 상태여야 합니다. 자세한 내용은 인증 기관 상태를 참조하세요.
    • CA에 활성 인증서가 없어야 합니다. CA를 영구적으로 삭제하기 전에 CA에서 발급한 인증서를 취소하는 것이 좋습니다. CA가 영구적으로 삭제된 후에는 활성 인증서를 취소할 수 없습니다.

CA 삭제

CA 삭제를 시작하려면 다음을 수행합니다.

콘솔

  1. Google Cloud 콘솔에서 Certificate Authority Service 페이지로 이동합니다.

    Certificate Authority Service로 이동

  2. CA 관리자 탭을 클릭합니다.
  3. CA 목록에서 삭제할 CA를 선택합니다.
  4. 사용 중지를 클릭합니다.
  5. 삭제할 CA를 사용 중지합니다.
  6. 대화상자가 열리면 확인을 클릭합니다.
  7. 삭제를 클릭합니다.
  8. 대화상자가 열리면 확인을 클릭합니다.

gcloud

  1. CA 상태를 확인하여 사용 중지되었는지 확인합니다. DISABLED 상태인 CA만 삭제할 수 있습니다.

    gcloud privateca roots describe CA_ID --pool=POOL_ID \
      --format="value(state)"
    

    다음을 바꿉니다.

    • CA_ID: CA의 고유 식별자입니다.
    • POOL_ID: CA가 포함된 CA 풀의 이름입니다.

    gcloud privateca roots describe 명령어에 대한 자세한 내용은 gcloud privateca roots describe를 참조하세요.

  2. CA가 사용 중지되지 않았으면 다음 명령어를 실행하여 CA를 사용 중지합니다.

    gcloud privateca roots disable CA_ID --pool=POOL_ID
    

    gcloud privateca roots disable 명령어에 대한 자세한 내용은 gcloud privateca roots disable을 참조하세요.

  3. CA를 삭제합니다.

    gcloud privateca roots delete CA_ID --pool=POOL_ID
    

    gcloud 명령어에 --ignore-active-certificates 플래그를 포함하면 CA에 활성 인증서가 있더라도 CA를 삭제할 수 있습니다.

    gcloud privateca roots delete 명령어에 대한 자세한 내용은 gcloud privateca roots delete를 참조하세요.

  4. 메시지가 표시되면 CA 삭제를 확인합니다.

    확인 후 CA 삭제가 예약되고 30일 유예 기간이 시작됩니다. 이 명령어는 CA 삭제가 예정된 날짜 및 시간을 출력합니다.

    Deleted Root CA [projects/PROJECT_ID/locations/us-west1/caPools/POOL_ID/certificateAuthorities/CA_ID] can be undeleted until 2020-08-14T19:28:39Z.
    

Go

CA Service에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	privateca "cloud.google.com/go/security/privateca/apiv1"
	"cloud.google.com/go/security/privateca/apiv1/privatecapb"
)

// Delete a Certificate Authority from the specified CA pool.
// Before deletion, the CA must be disabled or staged and must not contain any active certificates.
func deleteCa(w io.Writer, projectId string, location string, caPoolId string, caId string) error {
	// projectId := "your_project_id"
	// location := "us-central1"	// For a list of locations, see: https://cloud.google.com/certificate-authority-service/docs/locations.
	// caPoolId := "ca-pool-id"		// The id of the CA pool under which the CA is present.
	// caId := "ca-id"				// The id of the CA to be deleted.

	ctx := context.Background()
	caClient, err := privateca.NewCertificateAuthorityClient(ctx)
	if err != nil {
		return fmt.Errorf("NewCertificateAuthorityClient creation failed: %w", err)
	}
	defer caClient.Close()

	fullCaName := fmt.Sprintf("projects/%s/locations/%s/caPools/%s/certificateAuthorities/%s",
		projectId, location, caPoolId, caId)

	// Check if the CA is disabled or staged.
	// See https://pkg.go.dev/cloud.google.com/go/security/privateca/apiv1/privatecapb#GetCertificateAuthorityRequest.
	caReq := &privatecapb.GetCertificateAuthorityRequest{Name: fullCaName}
	caResp, err := caClient.GetCertificateAuthority(ctx, caReq)
	if err != nil {
		return fmt.Errorf("GetCertificateAuthority failed: %w", err)
	}

	if caResp.State != privatecapb.CertificateAuthority_DISABLED &&
		caResp.State != privatecapb.CertificateAuthority_STAGED {
		return fmt.Errorf("you can only delete disabled or staged Certificate Authorities. %s is not disabled", caId)
	}

	// Create the DeleteCertificateAuthorityRequest.
	// Setting the IgnoreActiveCertificates to True will delete the CA
	// even if it contains active certificates. Care should be taken to re-anchor
	// the certificates to new CA before deleting.
	// See https://pkg.go.dev/cloud.google.com/go/security/privateca/apiv1/privatecapb#DeleteCertificateAuthorityRequest.
	req := &privatecapb.DeleteCertificateAuthorityRequest{
		Name:                     fullCaName,
		IgnoreActiveCertificates: false,
	}

	op, err := caClient.DeleteCertificateAuthority(ctx, req)
	if err != nil {
		return fmt.Errorf("DeleteCertificateAuthority failed: %w", err)
	}

	if caResp, err = op.Wait(ctx); err != nil {
		return fmt.Errorf("DeleteCertificateAuthority failed during wait: %w", err)
	}

	if caResp.State != privatecapb.CertificateAuthority_DELETED {
		return fmt.Errorf("unable to delete Certificate Authority. Current state: %s", caResp.State.String())
	}

	fmt.Fprintf(w, "Successfully deleted Certificate Authority: %s.", caId)
	return nil
}

Java

CA Service에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.api.core.ApiFuture;
import com.google.cloud.security.privateca.v1.CertificateAuthority.State;
import com.google.cloud.security.privateca.v1.CertificateAuthorityName;
import com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient;
import com.google.cloud.security.privateca.v1.DeleteCertificateAuthorityRequest;
import com.google.longrunning.Operation;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class DeleteCertificateAuthority {

  public static void main(String[] args)
      throws InterruptedException, ExecutionException, IOException {
    // TODO(developer): Replace these variables before running the sample.
    // location: For a list of locations, see:
    // https://cloud.google.com/certificate-authority-service/docs/locations
    // poolId: The id of the CA pool under which the CA is present.
    // certificateAuthorityName: The name of the CA to be deleted.
    String project = "your-project-id";
    String location = "ca-location";
    String poolId = "ca-pool-id";
    String certificateAuthorityName = "certificate-authority-name";
    deleteCertificateAuthority(project, location, poolId, certificateAuthorityName);
  }

  // Delete the Certificate Authority from the specified CA pool.
  // Before deletion, the CA must be disabled and must not contain any active certificates.
  public static void deleteCertificateAuthority(
      String project, String location, String poolId, String certificateAuthorityName)
      throws IOException, ExecutionException, InterruptedException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the `certificateAuthorityServiceClient.close()` method on the client to safely
    // clean up any remaining background resources.
    try (CertificateAuthorityServiceClient certificateAuthorityServiceClient =
        CertificateAuthorityServiceClient.create()) {
      // Create the Certificate Authority Name.
      CertificateAuthorityName certificateAuthorityNameParent =
          CertificateAuthorityName.newBuilder()
              .setProject(project)
              .setLocation(location)
              .setCaPool(poolId)
              .setCertificateAuthority(certificateAuthorityName)
              .build();

      // Check if the CA is enabled.
      State caState =
          certificateAuthorityServiceClient
              .getCertificateAuthority(certificateAuthorityNameParent)
              .getState();
      if (caState == State.ENABLED) {
        System.out.println(
            "Please disable the Certificate Authority before deletion ! Current state: " + caState);
        return;
      }

      // Create the DeleteCertificateAuthorityRequest.
      // Setting the setIgnoreActiveCertificates() to true, will delete the CA
      // even if it contains active certificates. Care should be taken to re-anchor
      // the certificates to new CA before deleting.
      DeleteCertificateAuthorityRequest deleteCertificateAuthorityRequest =
          DeleteCertificateAuthorityRequest.newBuilder()
              .setName(certificateAuthorityNameParent.toString())
              .setIgnoreActiveCertificates(false)
              .build();

      // Delete the Certificate Authority.
      ApiFuture<Operation> futureCall =
          certificateAuthorityServiceClient
              .deleteCertificateAuthorityCallable()
              .futureCall(deleteCertificateAuthorityRequest);
      Operation response = futureCall.get();

      if (response.hasError()) {
        System.out.println("Error while deleting Certificate Authority !" + response.getError());
        return;
      }

      // Check if the CA has been deleted.
      caState =
          certificateAuthorityServiceClient
              .getCertificateAuthority(certificateAuthorityNameParent)
              .getState();
      if (caState == State.DELETED) {
        System.out.println(
            "Successfully deleted Certificate Authority : " + certificateAuthorityName);
      } else {
        System.out.println(
            "Unable to delete Certificate Authority. Please try again ! Current state: " + caState);
      }
    }
  }
}

Python

CA Service에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import google.cloud.security.privateca_v1 as privateca_v1

def delete_certificate_authority(
    project_id: str, location: str, ca_pool_name: str, ca_name: str
) -> None:
    """
    Delete the Certificate Authority from the specified CA pool.
    Before deletion, the CA must be disabled and must not contain any active certificates.

    Args:
        project_id: project ID or project number of the Cloud project you want to use.
        location: location you want to use. For a list of locations, see: https://cloud.google.com/certificate-authority-service/docs/locations.
        ca_pool_name: the name of the CA pool under which the CA is present.
        ca_name: the name of the CA to be deleted.
    """

    caServiceClient = privateca_v1.CertificateAuthorityServiceClient()
    ca_path = caServiceClient.certificate_authority_path(
        project_id, location, ca_pool_name, ca_name
    )

    # Check if the CA is enabled.
    ca_state = caServiceClient.get_certificate_authority(name=ca_path).state
    if ca_state != privateca_v1.CertificateAuthority.State.DISABLED:
        print(
            "Please disable the Certificate Authority before deletion ! Current state:",
            ca_state,
        )
        raise RuntimeError(
            f"You can only delete disabled Certificate Authorities. "
            f"{ca_name} is not disabled!"
        )

    # Create the DeleteCertificateAuthorityRequest.
    # Setting the ignore_active_certificates to True will delete the CA
    # even if it contains active certificates. Care should be taken to re-anchor
    # the certificates to new CA before deleting.
    request = privateca_v1.DeleteCertificateAuthorityRequest(
        name=ca_path, ignore_active_certificates=False
    )

    # Delete the Certificate Authority.
    operation = caServiceClient.delete_certificate_authority(request=request)
    result = operation.result()

    print("Operation result", result)

    # Get the current CA state.
    ca_state = caServiceClient.get_certificate_authority(name=ca_path).state

    # Check if the CA has been deleted.
    if ca_state == privateca_v1.CertificateAuthority.State.DELETED:
        print("Successfully deleted Certificate Authority:", ca_name)
    else:
        print(
            "Unable to delete Certificate Authority. Please try again ! Current state:",
            ca_state,
        )

삭제된 CA의 만료일 확인

CA가 영구적으로 삭제될 시점을 확인하려면 다음을 수행하세요.

콘솔

  1. CA 풀 관리자 탭을 클릭합니다.
  2. 삭제한 CA가 포함된 CA 풀의 이름을 클릭합니다.

CA 풀 페이지의 표에서 CA의 만료일을 확인할 수 있습니다.

삭제된 CA의 만료일 확인

gcloud

CA의 삭제 예정 시간을 확인하려면 다음 명령어를 실행하세요.

gcloud privateca roots describe CA_ID \
  --pool=POOL_ID \
  --format="value(expireTime.date())"

다음을 바꿉니다.

  • CA_ID: CA의 이름입니다.
  • POOL_ID: CA가 포함된 CA 풀의 이름입니다.

이 명령어는 CA Service가 CA를 삭제하도록 예정된 날짜 및 시간을 반환합니다.

2020-08-14T19:28:39

CA가 영구적으로 삭제되었는지 확인하려면 다음 명령어를 실행합니다.

gcloud privateca roots describe CA_ID --pool=POOL_ID

CA가 성공적으로 삭제되었으면 명령어가 다음 오류를 반환합니다.

ERROR: (gcloud.privateca.roots.describe) NOT_FOUND: Resource 'projects/PROJECT_ID/locations/LOCATION/caPools/POOL_ID/certificateAuthorities/CA_ID' was not found

다음 단계