ביטול אישורים

בדף הזה מוסבר איך לבטל אישורים.

‫Certificate Authority Service תומך בביטול אישורים על ידי פרסום תקופתי של רשימות אישורים שבוטלו (CRL). אפשר לבטל רק אישורים שהונפקו על ידי מאגרי CA ברמת Enterprise.

לפני שמתחילים

מוודאים שיש לכם את התפקיד 'מנהל תפעול של Certificate Authority Service' (roles/privateca.caManager) או 'אדמין של Certificate Authority Service' (roles/privateca.admin) בניהול זהויות והרשאות גישה (IAM). מידע נוסף על התפקידים המוגדרים מראש ב-IAM עבור CA Service זמין במאמר בקרת גישה באמצעות IAM.

במאמר הקצאת תפקיד יחיד מוסבר איך מקצים תפקיד ב-IAM.

הפעלת פרסום של CRL

כדי לבטל את האישורים שהונפקו על ידי מאגר CA, צריך להפעיל פרסום של CRL במאגר ה-CA. אפשר להפעיל פרסום של CRL במהלך יצירת מאגר CA. אם השבתתם את הפרסום של CRL בהתחלה, תוכלו להפעיל אותו בהמשך.

אחרי שמפעילים את הפרסום של CRL, מתפרסם CRL חדש מדי יום והוא תקף למשך 7 ימים. גם רשימת CRL חדשה מתפרסמת תוך 15 דקות מכל ביטול חדש של אישור.

האישורים מכילים תוסף של נקודת הפצה של CRL‏ (CDP) שמציין איפה אפשר למצוא את פרטי ה-CRL של האישור. כברירת מחדל, כשמפעילים פרסום של CRL, שירות CA מאכלס את התוסף CDP לכל האישורים שהונפקו על ידי ה-CA עם מיקום הפרסום ב-Cloud Storage שבו ה-CA משתמש. כדי להגדיר קישורים משלכם שיופיעו בתוסף האישור הזה, צריך להגדיר את UserDefinedAccessUrls. כדי לשמור את הקישור למיקום ברירת המחדל לפרסום ב-Cloud Storage וגם להוסיף קישורים משלכם, צריך להוסיף את הקישור ל-Cloud Storage לרשימת הקישורים שאתם מציינים.

כדי להפעיל פרסום של CRL במאגר CA:

המסוף

  1. נכנסים לדף Certificate Authority Service במסוףGoogle Cloud .

    Certificate Authority Service

  2. לוחצים על הכרטיסייה CA Pool Manager (ניהול מאגרים של רשויות אישורים).

  3. לוחצים על מאגר האישורים שרוצים לערוך או על מאגר האישורים שכולל את האישור שרוצים לערוך.

  4. בדף מאגר הרשות שמנפיקה את האישורים, לוחצים על .

    עריכה.

  5. לוחצים על הבא עד שמגיעים לקטע הגדרת אפשרויות הפרסום.

  6. לוחצים על המתג פרסום CRL בדלי GCS עבור רשויות אישורים במאגר הזה.

gcloud

מריצים את הפקודה הבאה:

gcloud privateca pools update POOL_ID --location LOCATION --publish-crl

מחליפים את מה שכתוב בשדות הבאים:

  • POOL_ID: השם של מאגר רשויות האישורים
  • LOCATION: המיקום של מאגר אישורי ה-CA. כאן מפורטת רשימת המיקומים המלאה.

מידע נוסף על הפקודה gcloud privateca pools update זמין במאמר gcloud privateca pools update.

שירות CA אוכף הגבלה של 500,000 אישורים שבוטלו ולא פג תוקפם לכל CRL.

רק 100 הרשימות האחרונות של אישורים שבוטלו בסדר כרונולוגי נשמרות כמשאבי CertificateRevocationList, ורשימות ישנות יותר נמחקות באופן אוטומטי. השמירה של רשימות CRL ישנות בקטגוריות Cloud Storage שמנוהלות על ידי הלקוח כפופה לניהול הגרסאות של האובייקטים ולמדיניות השמירה שהוגדרה על ידי הלקוחות.
שימו לב: עדיין אפשר לגשת לרשימות CRL שנמחקו מ-CA Service מקטגוריות Cloud Storage שמנוהלות על ידי השירות, אלא אם רשות האישורים נמחקת. רשימות CRL אף פעם לא נמחקות מקטגוריות של Cloud Storage שמנוהלות על ידי הלקוח, גם אם רשות האישורים נמחקת.

ביטול אישור

שירות CA מאפשר לבטל אישורים לפי מספר סידורי או שם משאב, ומקבל גם סיבה אופציונלית. אחרי שמבטלים אישור, המספר הסידורי שלו והסיבה לביטול מופיעים בכל רשימות ה-CRL העתידיות עד שהתוקף של האישור יפוג. רשימת CRL מחוץ למסגרת נוצרת גם היא תוך 15 דקות מביטול האישור.

כדי לבטל אישור, מבצעים את השלבים הבאים:

המסוף

  1. נכנסים לדף Certificate Authority Service במסוף Google Cloud .

    כניסה אל Certificate Authority Service

  2. לוחצים על הכרטיסייה ניהול אישורים פרטיים.
  3. ברשימת האישורים, לוחצים על הצגת פרטים נוספים בשורה של האישור שרוצים למחוק.
  4. לוחצים על ביטול.
  5. בתיבת הדו-שיח שנפתחת, לוחצים על אישור.

gcloud

  • כדי לבטל אישור באמצעות שם המשאב שלו, מריצים את הפקודה הבאה:

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

    מחליפים את מה שכתוב בשדות הבאים:

    • CERT_ID: המזהה הייחודי של האישור שרוצים לבטל
    • POOL_ID: שם מאגר ה-CA שהנפיק את האישור
    • ISSUER_LOCATION: המיקום של מאגר רשויות האישורים המנפיקות
    • 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 \
        --issuer-location ISSUER_LOCATION \
        --reason REVOCATION_REASON
    

    מחליפים את מה שכתוב בשדות הבאים:

    • SERIAL_NUMBER: המספר הסידורי של האישור
    • POOL_ID: השם של מאגר רשויות האישורים שהנפיק את האישור
    • ISSUER_LOCATION: המיקום של מאגר רשויות האישורים המנפיקות
    • 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.
    
    

המשך

כדי לבצע אימות ב-CA Service, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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)

המאמרים הבאים