Deploy a global self-managed certificate

This tutorial shows you how to use Certificate Manager to deploy a global self-managed certificate.

The following load balancers support global self-managed certificates:

  • Global external Application Load Balancer
  • Classic Application Load Balancer
  • Global external proxy Network Load Balancer
  • Classic proxy Network Load Balancer

If you want to deploy to regional or cross-region load balancers, see thefollowing:

Objectives

This tutorial shows you how to complete the following tasks:

  • Upload a self-managed certificate to Certificate Manager.
  • Deploy the certificate to a supported load balancer by using a target HTTPSproxy.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Compute Engine, Certificate Manager APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  5. Install the Google Cloud CLI.

    Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.
  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. Toinitialize the gcloud CLI, run the following command:

    gcloudinit
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.create permission.Learn how to grant roles.
    Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.

    Go to project selector

  9. Verify that billing is enabled for your Google Cloud project.

  10. Enable the Compute Engine, Certificate Manager APIs.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enable permission.Learn how to grant roles.

    Enable the APIs

  11. Install the Google Cloud CLI.

    Note: If you installed the gcloud CLI previously, make sure you have the latest version by runninggcloud components update.
  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. Toinitialize the gcloud CLI, run the following command:

    gcloudinit

Required roles

Make sure that you have the following roles to complete the tasks in this tutorial:

  • Certificate Manager Owner (roles/certificatemanager.owner)

    Required to create and manage Certificate Manager resources.

  • Compute Load Balancer Admin (roles/compute.loadBalancerAdmin) or Compute Network Admin (roles/compute.networkAdmin)

    Required to create and manage HTTPS target proxy.

For more information, see the following:

Note: If you aren't assigned the permissions or roles, request the missing rolesfrom the Identity and Access Management (IAM) administrator who has the ProjectIAM Admin role (roles/resourcemanager.projectIamAdmin).

Create the load balancer

This tutorial assumes that you've already created and configured the loadbalancer's backends, health checks, backend services, and URL maps. If you'vecreated an external Application Load Balancer, note the name of the URL map because you need itlater in this tutorial.

If you haven't created the load balancer, see the following pages to create one:

Create a private key and certificate

To create a private key and a certificate, do the following:

  1. Use a trusted third-party certificate authority (CA) to issue thecertificate along with its associated key.

  2. Verify that the certificate is properly chained and root-trusted.

  3. Prepare the following PEM-encoded files:

    • The certificate file (CRT)
    • The corresponding private key file (KEY)

For information about how to request and validate a certificate, seeCreate aprivate key andcertificate.

Upload a self-managed certificate to Certificate Manager

To upload the certificate to Certificate Manager, do thefollowing:

Console

  1. In the Google Cloud console, go to theCertificate Manager page.

    Go to Certificate Manager

  2. On theCertificates tab, clickAdd Certificate.

  3. In theCertificate name field, enter a unique name for thecertificate.

  4. Optional: In theDescription field, enter a description for thecertificate. The description lets you identify the certificate.

  5. ForLocation, selectGlobal.

  6. ForScope, selectDefault.

  7. ForCertificate type, selectCreate self-managed certificate.

  8. For theCertificate field, doeither of the following:

    • Click theUpload button and select your PEM-formattedcertificate file.
    • Copy and paste the contents of a PEM-formatted certificate. Thecontents must start with-----BEGIN CERTIFICATE----- and endwith-----END CERTIFICATE-----.
  9. For thePrivate key certificate field, doeither of the following:

    • Click theUpload button and select your private key. Yourprivate key must be PEM-formatted and not protected with apassphrase.
    • Copy and paste the contents of a PEM-formatted private key. Theprivate keys must start with-----BEGIN PRIVATE KEY----- andend with-----END PRIVATE KEY-----.
  10. In theLabels field, specify labels to associate with thecertificate. To add a label, clickAdd label, and specifya key and a value for your label.

  11. ClickCreate.

    The new certificate appears in the list of certificates.

gcloud

To create a global self-managed certificate, use thecertificate-manager certificates create command:

gcloud certificate-manager certificates createCERTIFICATE_NAME \    --certificate-file="CERTIFICATE_FILE" \    --private-key-file="PRIVATE_KEY_FILE"

Replace the following:

  • CERTIFICATE_NAME: the name of the certificate.
  • CERTIFICATE_FILE: the path and filename of the CRT certificate file.
  • PRIVATE_KEY_FILE: the path and filename of the KEY private key file.

Terraform

To upload a self-managed certificate, you can use agoogle_certificate_manager_certificate resource with theself_managed block.

API

Upload the certificate by making aPOST request to thecertificates.create method as follows:

POST /v1/projects/PROJECT_ID/locations/global/certificates?certificate_id=CERTIFICATE_NAME{  self_managed: {    pem_certificate: "PEM_CERTIFICATE",    pem_private_key: "PEM_KEY",  }}

Replace the following:

  • PROJECT_ID: the ID of the Google Cloud project.
  • CERTIFICATE_NAME: the name of the certificate.
  • PEM_CERTIFICATE: the certificate PEM.
  • PEM_KEY: the key PEM.

Deploy the self-managed certificate to a load balancer

To deploy the global self-managed certificate, use acertificate map.

Create a certificate map

Create a certificate map that references the certificate map entry associatedwith your certificate:

gcloud

To create a certificate map, use thegcloud certificate-manager maps create command:

gcloud certificate-manager maps createCERTIFICATE_MAP_NAME

ReplaceCERTIFICATE_MAP_NAME with the name of the targetcertificate map.

Terraform

To create a certificate map, you can use agoogle_certificate_manager_certificate_map resource.

resource "google_certificate_manager_certificate_map" "certificate_map" {  name        = "${local.name}-certmap-${random_id.tf_prefix.hex}"  description = "${local.domain} certificate map"  labels = {    "terraform" : true  }}

Create a certificate map entry

Create a certificate map entry and associate it with your certificate andcertificate map:

gcloud

To create a certificate map entry, use thegcloud certificate-manager maps entries create command:

gcloud certificate-manager maps entries createCERTIFICATE_MAP_ENTRY_NAME \    --map="CERTIFICATE_MAP_NAME" \    --certificates="CERTIFICATE_NAME" \    --hostname="HOSTNAME"

Replace the following:

  • CERTIFICATE_MAP_ENTRY_NAME: the name of the certificate map entry.
  • CERTIFICATE_MAP_NAME: the name of the certificate map to which the certificate map entry is attached.
  • CERTIFICATE_NAME: the name of the certificate you want to associate with the certificate map entry.
  • HOSTNAME: the hostname that you want to associate with the certificate map entry.

    If you want to create a certificate that covers both a wildcard domainand a root domain, then specify the hostname with a root and a wildcard,such asexample.com and*.example.com. In addition, you must specifytwo certificate map entries - one forexample.com and the other for*.example.com.

Terraform

To create a certificate map entry with a root domain, use agoogle_certificate_manager_certificate_map_entry resource.

resource "google_certificate_manager_certificate_map_entry" "first_entry" {  name        = "${local.name}-first-entry-${random_id.tf_prefix.hex}"  description = "example certificate map entry"  map         = google_certificate_manager_certificate_map.certificate_map.name  labels = {    "terraform" : true  }  certificates = [google_certificate_manager_certificate.root_cert.id]  hostname     = local.domain}

To create a certificate map entry with a wildcard domain, use agoogle_certificate_manager_certificate_map_entry resource.

resource "google_certificate_manager_certificate_map_entry" "second_entry" {  name        = "${local.name}-second-entity-${random_id.tf_prefix.hex}"  description = "example certificate map entry"  map         = google_certificate_manager_certificate_map.certificate_map.name  labels = {    "terraform" : true  }  certificates = [google_certificate_manager_certificate.root_cert.id]  hostname     = "*.${local.domain}"}

Verify that the certificate map entry is active

Verify that the certificate map entry is active before attaching itscorresponding certificate map to the target proxy.

To verify the certificate map entry, use thegcloud certificate-manager maps entries describe command:

gcloud certificate-manager maps entries describeCERTIFICATE_MAP_ENTRY_NAME \    --map="CERTIFICATE_MAP_NAME"

Replace the following:

  • CERTIFICATE_MAP_ENTRY_NAME: the name of the certificate map entry.
  • CERTIFICATE_NAME: the name of the certificate you want to associate with the certificate map entry.

The output is similar to the following:

certificates:createTime: '2021-09-06T10:01:56.229472109Z'hostname: example.comname: projects/my-project/locations/global/certificateMaps/myCertMap/certificateMapEntries/myCertMapEntrystate: ACTIVEupdateTime: '2021-09-06T10:01:58.277031787Z'

Attach the certificate map to the target proxy

You can attach the certificate map to a new target proxy or an existing targetproxy.

gcloud

To attach the certificate map to a new target proxy, use thegcloud compute target-https-proxies create command:

gcloud compute target-https-proxies createPROXY_NAME \    --certificate-map="CERTIFICATE_MAP_NAME" \    --url-map="URL_MAP" \    --global

Replace the following:

  • PROXY_NAME: the name of the target proxy.
  • CERTIFICATE_MAP_NAME: the name of the certificate map referencing the certificate map entry and theassociated certificate.
  • URL_MAP: the name of the URL map

To attach the certificate map to an existing target HTTPS proxy, use thegcloud compute target-https-proxies update command. If you don't know the name of the existingtarget proxy, go to theTarget proxies page and note the name of thetarget proxy.

gcloud compute target-https-proxies updatePROXY_NAME \    --certificate-map="CERTIFICATE_MAP_NAME" \    --global

After creating or updating the target proxy, run the following command toverify it:

gcloud compute target-https-proxies list

Terraform

To attach the certificate map to the target proxy, you can use agoogle_compute_target_https_proxy resource.

When configuring a target proxy, if you attach TLS (SSL) certificates directlyand also through a certificate map, the proxy uses the certificates referencedby the certificate map and ignores the directly attached TLS (SSL) certificates.

Clean up

To avoid incurring charges to your Google Cloud account for the resourcesused in this tutorial, delete them.

  1. Delete the load balancer and its resources.

    SeeClean up a load balancing setup.

  2. Delete or detach the certificate map from the proxy.

    To delete the certificate map, run the following command:

    gcloud compute target-https-proxies deletePROXY_NAME

    If you want to keep the target HTTPS proxy, then detach thecertificate map from the proxy.

    Caution: Before you detach the certificate map, notethe following considerations.
    • If there are any TLS (SSL) certificates attached directly to the proxy,then detaching the certificate map causes the proxy to resume using thosedirectly attached TLS (SSL) certificates.
    • If there are no TLS (SSL) certificates attached directly to the proxy,then the certificate map can't be detached from the proxy. You must firstattach at least one TLS (SSL) certificate directly to the proxy beforeyou can detach the certificate map.

    To detach the certificate map, run the following command:

    gcloud compute target-https-proxies updatePROXY_NAME \    --clear-certificate-map

    ReplacePROXY_NAME with the name of the target proxy.

  3. Delete the certificate map entry from the certificate map:

    gcloud certificate-manager maps entries deleteCERTIFICATE_MAP_ENTRY_NAME \    --map="CERTIFICATE_MAP_NAME"

    Replace the following:

    • CERTIFICATE_MAP_ENTRY_NAME: the name of the certificate map entry.
    • CERTIFICATE_MAP_NAME: the name of the certificate map.
  4. Delete the certificate map:

    gcloud certificate-manager maps deleteCERTIFICATE_MAP_NAME

    ReplaceCERTIFICATE_MAP_NAME with the name of thecertificate map.

  5. Delete the uploaded certificate:

    gcloud certificate-manager certificates deleteCERTIFICATE_NAME

    ReplaceCERTIFICATE_NAME with the name of the certificate.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.