This tutorial walks you through the certificate deployment process using a Google-managed certificate with load balancer authorization as an example.
For a comparison of the supported types of domain authorization, see Domain authorization.
The following load balancers support Google-managed certificates with load balancer authorization:
- Global external Application Load Balancer
- Classic Application Load Balancer
- Global external proxy Network Load Balancer
If you want to migrate an existing certificate to Certificate Manager, follow the steps in Migrate certificates to Certificate Manager instead.
Objectives
This tutorial shows you how to complete the following tasks:
- Create a Google-managed certificate issued by a publicly trusted CA with load balancer authorization by using Certificate Manager.
- Deploy the certificate to a supported load balancer by using a target HTTPS proxy.
For more information about the certificate deployment process, see Deployment overview.
If you are following the steps in this tutorial to deploy a certificate for a domain that is already serving production traffic keep in mind that traffic for that domain will be interrupted while the certificate is provisioned and activated on the corresponding load balancer.
Before you begin
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Make sure that you have the following roles to complete the tasks in this tutorial:
- Certificate Manager Owner: Required to create and manage Certificate Manager resources.
- Compute Load Balancer Admin or Compute Network Admin: Required to create and manage HTTPS target proxy.
- DNS Administrator: Required if you want to use Cloud DNS as your DNS solution.
For more information, see the following:
- Roles and permissions for Certificate Manager
- Compute Engine IAM roles and permissions for Compute Engine
- Access control with IAM for Cloud DNS
Create a Google-managed certificate with load balancer authorization
To create a Google-managed certificate with load balancer authorization, complete the steps in this section.
To specify multiple domain names for the certificate, provide a comma-delimited list of target domain names for the certificate.
For more information, see Permissions and roles.
Console
In the Google Cloud console, go to the Certificate Manager page.
On the page that appears, select the Certificates tab.
Click Add Certificate.
Enter a Name for the certificate.
This name must be unique for the project.
Optional: Enter the Description for the certificate. The description helps you identify a specific certificate later.
For location, choose Global.
For Scope, choose Default.
For Certificate type, choose Create Google-managed certificate.
For Certificate Authority type, choose Public.
Specify the Domain Names of the certificate. Enter a comma-delimited list of the target domains. Also, each domain name must be a fully qualified domain name, such as
myorg.example.com
.For Authorization type, choose Load Balancer Authorization.
Specify a label to associate to the certificate. You can add more than one label, if needed. To add a label, click the add_box Add label button, and specify a
key
and avalue
for your label.Click Create. Verify that the new certificate appears in the list of certificates.
gcloud
gcloud certificate-manager certificates create CERTIFICATE_NAME \ --domains="DOMAIN_NAMES"
Replace the following:
CERTIFICATE_NAME
: a unique name of the certificate.DOMAIN_NAMES
: a comma-delimited list of the target domains for this certificate. Each domain name must be a fully qualified domain name, such asmyorg.example.com
.
Terraform
Use a google_certificate_manager_certificate
resource.
To learn how to apply or remove a Terraform configuration, see Basic Terraform commands.
API
Create the certificate by making a POST
request to the
certificates.create
method as follows:
POST /v1/projects/PROJECT_ID/locations/global/certificates?certificate_id=CERTIFICATE_NAME" { "managed": { "domains": ["DOMAIN_NAME"], } }
Replace the following:
PROJECT_ID
: the ID of the target Google Cloud project.CERTIFICATE_NAME
: a unique name that describes this certificate.DOMAIN_NAME
: the target domain for this certificate. The domain name must be a fully qualified domain name, such asmyorg.example.com
.
For an overview of the certificate deployment process, see Deployment overview.
Deploy the certificate to a load balancer
Complete the steps in this section to deploy the Google-managed certificate you created in the previous steps to a load balancer.
Create a certificate map
Create a certificate map that references the certificate map entry associated with your certificate.
gcloud
gcloud certificate-manager maps create CERTIFICATE_MAP_NAME
Replace CERTIFICATE_MAP_NAME
with the name of the target
certificate map.
Terraform
Create a certificate map entry
Create a certificate map entry and associate it with your certificate as well as your certificate map.
gcloud
gcloud certificate-manager maps entries create CERTIFICATE_MAP_ENTRY_NAME \ --map="CERTIFICATE_MAP_NAME" \ --certificates="CERTIFICATE_NAME" \ --hostname="HOSTNAME"
Replace the following:
CERTIFICATE_MAP_ENTRY_NAME
: a unique name of the certificate map entryCERTIFICATE_MAP_NAME
: the name of the certificate map to which this certificate map entry attachesCERTIFICATE_NAME
: the name of the certificate you want to associate with this certificate map entryHOSTNAME
: the hostname that you want to associate with this certificate map entry
Terraform
Use a google_certificate_manager_certificate_map_entry
resource.
Verify that the certificate map entry is active
Use the following command to verify that the certificate map entry is active before attaching its corresponding certificate map to the target proxy:
gcloud certificate-manager maps entries describe CERTIFICATE_MAP_ENTRY_NAME \ --map="CERTIFICATE_MAP_NAME"
Replace the following:
CERTIFICATE_MAP_ENTRY_NAME
: the name of the target certificate map entryCERTIFICATE_MAP_NAME
: the name of the certificate map to which this certificate map entry attaches
The command returns output similar to the following:
certificates: createTime: '2021-09-06T10:01:56.229472109Z' hostname: example.com name: projects/my-project/locations/global/certificateMaps/myCertMap/certificateMapEntries/myCertMapEntry state: ACTIVE updateTime: '2021-09-06T10:01:58.277031787Z'
Attach the certificate map to the target proxy
Attach the configured certificate map to the target proxy.
Console
- In the Google Cloud console, go to the Target proxies page.
Note the name of the target proxy.
Attach the certificate map to the target proxy:
gcloud compute target-https-proxies update PROXY_NAME \ --certificate-map="CERTIFICATE_MAP_NAME"
Replace the following:
* `PROXY_NAME`: the name of the target proxy
* `CERTIFICATE_MAP_NAME`: the name of the certificate
map referencing your certificate map entry and its associated
certificate
Terraform
If there are any existing TLS (SSL) certificates attached directly to the proxy, the proxy gives preference to the certificates referenced by the certificate map over the directly attached TLS (SSL) certificates.
Wait until the certificate has been activated
After you have attached the certificate to the target proxy, it can take up to
several hours for the certificate to be issued and its status change to
ACTIVE
. Once the status is ACTIVE
, it can take up to 30 minutes for the load
balancer to start using the certificate.
Use the following command to check the status of the certificate:
gcloud certificate-manager certificates describe CERTIFICATE_NAME
Replace CERTIFICATE_NAME
with the name of the target
Google-managed certificate.
The command returns output similar to the following:
createTime: '2021-10-20T12:19:53.370778666Z' expireTime: '2022-05-07T05:03:49Z' managed: authorizationAttemptInfo: - domain: myorg.example.com state: AUTHORIZED domains: - myorg.example.com state: ACTIVE name: projects/myProject/locations/global/certificates/myCert sanDnsnames: - myorg.example.com updateTime: '2021-10-20T12:19:55.083385630Z'
If the certificate status has not changed to ACTIVE
after several hours, check
the following:
- The certificate map referencing this certificate has been attached to the correct target proxy as described in Attach a certificate map to a proxy.
- The target proxy has been attached to the correct load balancer as described
in Verify the target proxy
association.
- The target domain's DNS configuration points to the target load balancer's IP address as described in Update the DNS A and AAAA records to point to the load balancer's IP address.
For more troubleshooting steps, see Troubleshooting SSL certificates.
Clean up
To revert the changes you have made in this tutorial, complete the following steps:
Detach the certificate map from the proxy.
Before you detach the certificate map, note the following:
- If there were any TLS (SSL) certificates attached directly to the proxy, detaching the certificate map causes the proxy to resume using those directly attached TLS (SSL) certificates.
- If there were no TLS (SSL) certificates attached directly to the proxy, the certificate map can't be detached from the proxy. You must first attach at least one TLS (SSL) certificate directly to the proxy before you can detach the certificate map.
To detach the certificate map, run the following command:
gcloud compute target-https-proxies update PROXY_NAME \ --clear-certificate-map
Delete the certificate map entry from the certificate map:
gcloud certificate-manager maps entries delete CERTIFICATE_MAP_ENTRY_NAME \ --map="CERTIFICATE_MAP_NAME"
Replace the following:
CERTIFICATE_MAP_ENTRY_NAME
: the name of the target certificate map entryCERTIFICATE_MAP_NAME
: the name of the target certificate map
Delete the certificate map:
gcloud certificate-manager maps delete CERTIFICATE_MAP_NAME
Replace
CERTIFICATE_MAP_NAME
with the name of the target certificate map.Delete the Google-managed certificate:
gcloud certificate-manager certificates delete CERTIFICATE_NAME
Replace
CERTIFICATE_NAME
with the name of the target certificate.