인증서 취소

이 페이지에서는 인증서를 취소하는 방법을 설명합니다.

Certificate Authority Service는 해지 인증서 목록(CRL)을 주기적으로 게시하여 인증서 해지를 지원합니다. Enterprise 등급의 CA 풀에서 발급한 인증서만 취소할 수 있습니다.

시작하기 전에

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

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

CRL 게시 사용 설정

CA 풀에서 발급한 인증서를 취소하려면 CA 풀에서 CRL 게시를 사용 설정해야 합니다. CA 풀을 만드는 동안 CRL 게시를 사용 설정할 수 있습니다. 처음에 사용 중지된 경우 나중에 CRL 게시를 사용 설정할 수 있습니다.

CRL 게시를 사용 설정하면 새 CRL이 매일 게시되며 7일 동안 유효합니다. 또한 새 인증서 취소 후 15분 이내에 새 CRL이 게시됩니다.

CA 풀에서 CRL 게시를 사용 설정하려면 다음을 수행합니다.

콘솔

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

    Certificate Authority Service

  2. CA 풀에서 수정할 CA의 이름을 클릭합니다.

  3. 인증 기관 페이지에서 정책 수정을 클릭합니다.

  4. 표시되는 왼쪽 패널의 게시 옵션에서 발급된 인증서의 해지 인증서 목록에 대한 액세스 URL 게시 전환 버튼을 클릭합니다.

gcloud

다음 명령어를 실행합니다.

gcloud privateca pools update POOL_ID \
  --publish-crl

POOL_ID를 CA 풀의 이름으로 바꿉니다.

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

CA Service는 CRL당 만료되지 않은 취소 인증서에 500,000개의 한도를 적용합니다.

인증서 취소

CA Service는 일련번호 또는 리소스 이름으로 인증서를 해지할 수 있고 이유를 입력할 수도 있습니다. 인증서가 취소되면 인증서가 만료일에 도달할 때까지 해당 일련번호와 취소 이유가 이후의 모든 CRL에 표시됩니다. 또한 취소 후 15분 이내에 대역 외 CRL이 생성됩니다.

인증서를 취소하려면 다음 단계를 따르세요.

콘솔

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

    Certificate Authority Service로 이동

  2. 비공개 인증서 관리자 탭을 클릭합니다.
  3. 인증서 목록에서 삭제할 인증서 행의 더보기를 클릭합니다.
  4. 취소를 클릭합니다.
  5. 대화상자가 열리면 확인을 클릭합니다.

gcloud

  • 리소스 이름을 사용하여 인증서를 취소하려면 다음 명령어를 실행합니다.

    gcloud privateca certificates revoke \
      --certificate CERT_ID \
      --issuer-pool POOL_ID \
      --reason REVOCATION_REASON
    

    다음을 바꿉니다.

    • CERT_ID: 취소할 인증서의 고유 식별자입니다.
    • POOL_ID: 인증서를 발급한 CA 풀의 이름입니다.
    • REVOCATION_REASON: 인증서를 취소한 이유입니다.

    --reason 플래그는 선택사항입니다. 이 플래그에 대한 자세한 내용은 --reason을 참조하거나 다음 gcloud 명령어를 --help 플래그와 함께 사용하세요.

    gcloud privateca certificates revoke --help
    

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

  • 일련번호를 사용하여 인증서를 취소하려면 다음 명령어를 실행합니다.

    gcloud privateca certificates revoke \
      --serial-number SERIAL_NUMBER \
      --issuer-pool POOL_ID \
      --reason REVOCATION_REASON
    

    다음을 바꿉니다.

    • SERIAL_NUMBER: 클라이언트 인증서의 일련번호입니다.
    • POOL_ID: 인증서를 발급한 CA 풀의 이름입니다.
    • REVOCATION_REASON: 인증서를 취소한 이유입니다.

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

    확인 메시지가 표시되면 'Y'를 입력하여 확인할 수 있습니다.

    You are about to revoke Certificate [projects/PROJECT_ID/locations/CA_POOL_REGION/caPools/POOL_ID/certificates/CERT_ID]
    
    Do you want to continue? (Y/n) Y
    Revoked certificate [projects/PROJECT_ID/locations/CA_POOL_REGION/caPools/POOL_ID/certificates/CERT_ID] at DATE_TIME.
    
    

Go

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

import (
	"context"
	"fmt"
	"io"

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

// Revoke an issued certificate. Once revoked, the certificate will become invalid
// and will expire post its lifetime.
func revokeCertificate(
	w io.Writer,
	projectId string,
	location string,
	caPoolId string,
	certId 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 CA Pool id in which the certificate exists.
	// certId := "certificate"			// A unique name for the certificate.

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

	fullCertName := fmt.Sprintf("projects/%s/locations/%s/caPools/%s/certificates/%s", projectId, location,
		caPoolId, certId)

	// Create the RevokeCertificateRequest and specify the appropriate revocation reason.
	// See https://pkg.go.dev/cloud.google.com/go/security/privateca/apiv1/privatecapb#RevokeCertificateRequest.
	req := &privatecapb.RevokeCertificateRequest{
		Name:   fullCertName,
		Reason: privatecapb.RevocationReason_PRIVILEGE_WITHDRAWN,
	}

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

	fmt.Fprintf(w, "Certificate %s revoked", certId)

	return nil
}

Java

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


import com.google.api.core.ApiFuture;
import com.google.cloud.security.privateca.v1.Certificate;
import com.google.cloud.security.privateca.v1.CertificateAuthorityServiceClient;
import com.google.cloud.security.privateca.v1.CertificateName;
import com.google.cloud.security.privateca.v1.RevocationReason;
import com.google.cloud.security.privateca.v1.RevokeCertificateRequest;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class RevokeCertificate {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    // 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: Id for the CA pool which contains the certificate.
    // certificateName: Name of the certificate to be revoked.
    String project = "your-project-id";
    String location = "ca-location";
    String poolId = "ca-pool-id";
    String certificateName = "certificate-name";
    revokeCertificate(project, location, poolId, certificateName);
  }

  // Revoke an issued certificate. Once revoked, the certificate will become invalid and will expire
  // post its lifetime.
  public static void revokeCertificate(
      String project, String location, String poolId, String certificateName)
      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 Certificate Name.
      CertificateName certificateNameParent =
          CertificateName.newBuilder()
              .setProject(project)
              .setLocation(location)
              .setCaPool(poolId)
              .setCertificate(certificateName)
              .build();

      // Create Revoke Certificate Request and specify the appropriate revocation reason.
      RevokeCertificateRequest revokeCertificateRequest =
          RevokeCertificateRequest.newBuilder()
              .setName(certificateNameParent.toString())
              .setReason(RevocationReason.PRIVILEGE_WITHDRAWN)
              .build();

      // Revoke certificate.
      ApiFuture<Certificate> response =
          certificateAuthorityServiceClient
              .revokeCertificateCallable()
              .futureCall(revokeCertificateRequest);
      Certificate certificateResponse = response.get();

      System.out.println("Certificate Revoked: " + certificateResponse.getName());
    }
  }
}

Python

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


import google.cloud.security.privateca_v1 as privateca_v1

def revoke_certificate(
    project_id: str,
    location: str,
    ca_pool_name: str,
    certificate_name: str,
) -> None:
    """
    Revoke an issued certificate. Once revoked, the certificate will become invalid and will expire post its lifetime.

    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: name for the CA pool which contains the certificate.
        certificate_name: name of the certificate to be revoked.
    """

    caServiceClient = privateca_v1.CertificateAuthorityServiceClient()

    # Create Certificate Path.
    certificate_path = caServiceClient.certificate_path(
        project_id, location, ca_pool_name, certificate_name
    )

    # Create Revoke Certificate Request and specify the appropriate revocation reason.
    request = privateca_v1.RevokeCertificateRequest(
        name=certificate_path, reason=privateca_v1.RevocationReason.PRIVILEGE_WITHDRAWN
    )
    result = caServiceClient.revoke_certificate(request=request)

    print("Certificate revoke result:", result)

다음 단계