Request a certificate
This page describes how you can create a certificate request in Certificate Authority Service.
You can request a certificate using the following methods:
- Generate your own private or public key and submit a Certificate Signing Request (CSR).
- Use a private or public key auto-generated by CA Service.
- Use an existing Cloud Key Management Service (Cloud KMS) key.
Before you begin
To get the permissions that you need to issue certificates, ask your administrator to grant you the CA Service Certificate Requester (
roles/privateca.certificateRequester
) or the CA Service Certificate Manager (roles/privateca.certificateManager
) IAM role.For more information about the predefined IAM roles for CA Service, see Access control with IAM.
For information about granting an IAM role to a principal, see Grant a single role.
Request certificate using a CSR
To obtain a certificate, you generate a CSR, which you then use to request the certificate.
Generate the CSR
For detailed instructions on how to generate a CSR using OpenSSL, see How to generate CSR with OpenSSL. You can also use the following sample configuration file as a reference when generating your CSR.
To use the sample configuration file, follow these steps:
Create a configuration file named
csr.cnf
using the following configuration.cat << EOF > csr.cnf [req] distinguished_name = req_distinguished_name req_extensions = v3_req prompt = no [req_distinguished_name] CN = example.com [v3_req] keyUsage = critical, digitalSignature, keyEncipherment extendedKeyUsage = serverAuth subjectAltName = @alt_names [alt_names] DNS.1 = example.com DNS.2 = www.example.com EOF
This sample generates a 2048-bit RSA key (passphrase encrypted) and a corresponding CSR containing the following:
- the
commonName
attribute in the subject DN - the
subjectAlternativeName
extension - the
keyUsage
extension (marked critical) - the
extendedKeyUsage
extension
Modify the parameters as required. To use the
x509v3_config
configuration file format to define extensions for X.509 certificates and CSRs, refer to the OpenSSL documentation.- the
Run the following
openssl
command to generate a CSR and a corresponding private key:openssl req -newkey rsa:2048 -out csr.pem -keyout key.pem -config csr.cnf
This command generates the following files:
csr.pem
: your CSR, ready to be submitted to a CAkey.pem
: your private key, which you should keep secure
Use the
csr.pem
file in your certificate request.
Submit certificate request using the CSR
To request a certificate using the CSR, follow these steps:
Console
Go to the Certificate Authority Service page on the Google Cloud console.
Click Request a certificate.
Select a region. The region must be the same as the region of the CA pool that you intend to use.
Select a CA pool.
Optional: Select a specific CA from the CA pool. Note that when you choose a specific CA for certificate issuance, you create a dependency on that CA, making it harder to rotate CAs.
Optional: Choose a certificate template. If you use a certificate template, make sure that the certificate template's policies don't conflict with the selected CA pool's policies.
Click Provide Certificate Signing Request (CSR), and then click Next. The certificate details are displayed.
Optional: To overwrite the automatically generated certificate name, enter the custom name in the Certificate name field. After the certificate is created, you can't delete or reuse the certificate name.
Optional: To choose a custom validity period for the certificate, enter the value in the Valid for field.
Copy and paste your CSR in the Certificate CSR box. If you want to upload a file containing the CSR, click Browse, and then choose your file.
Click Generate certificate.
Download the signed certificate
- To see the generated certificate, click View certificate, and then click View.
- To copy the certificate, click
.crt
file, click Download certificate.
.
To download the certificate in the form of a - Optional: To download the certificate chain, click Download certificate chain.
gcloud
gcloud privateca certificates create CERT_ID \
--issuer-pool POOL_ID \
--csr CSR_FILENAME \
--cert-output-file CERT_FILENAME \
--validity "P30D"
Replace the following:
- CERT_ID: The unique identifier of the certificate.
- POOL_ID: The name of the CA pool.
- CSR_FILENAME: The file that stores the PEM-encoded CSR.
The --validity
flag defines the duration the certificate is valid. It is an optional flag whose default value is 30 days.
For more information about the gcloud privateca certificates create
command, see gcloud privateca certificates create.
Terraform
REST API
Generate a Certificate Signing Request (CSR) using your preferred method, such as
openssl
.The following is a sample CSR that is encoded for JSON.
-----BEGIN CERTIFICATE REQUEST-----\nMIIChTCCAW0CAQAwQDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ8wDQYDVQQK\nDAZKb29uaXgxEzARBgNVBAMMCmpvb25peC5uZXQwggEiMA0GCSqGSIb3DQEBAQUA\nA4IBDwAwggEKAoIBAQCnyy+5vcRQUBPqAse3ojmWjyUvhcJK6eLRXpp0teEUF5kg\nHb2ov8gYXb9sSim5fnvs09dGYDKibSrL4Siy7lA/NzMzWtKwyQQeLIQq/cLUJVcd\ndItJ0VRcqr+UPkTCii2vrdcocNDChHM1J8chDdl6DkpYieSTqZwlPcWlQBGAINmT\nT3Q0ZarIVM5l74j13WPuToGrhbVOIZXWxWqJjlHbBA8B/VKtSRCzM1qG60y8Pu2f\n6c78Dfg8+CGRzGwnz8aFS0Yf9czT9luNHSadS/RHjvE9FPZCsinz+6mJlXRcphi1\nKaHsDbstUAhse1h5E9Biyr9SFYRHxY7qRv9aSJ/dAgMBAAGgADANBgkqhkiG9w0B\nAQsFAAOCAQEAZz+I9ff1Rf3lTewXRUpA7nr5HVO1ojCR93Pf27tI/hvNH7z7GwnS\noScoJlClxeRqABOCnfmVoRChullb/KmER4BZ/lF0GQpEtbqbjgjkEDpVlBKCb0+L\nHE9psplIz6H9nfFS3Ouoiodk902vrMEh0LyDYNQuqFoyCZuuepUlK3NmtmkexlgT\n0pJg/5FV0iaQ+GiFXSZhTC3drfiM/wDnXGiqpbW9WmebSij5O+3BNYXKBUgqmT3r\nbryFydNq4qSOIbnN/MNb4UoKno3ve7mnGk9lIDf9UMPvhl+bT7C3OLQLGadJroME\npYnKLoZUvRwEdtZpbNL9QhCAm2QiJ6w+6g==\n-----END CERTIFICATE REQUEST-----
Request a certificate.
HTTP method and URL:
POST https://privateca.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/caPools/POOL_ID/certificates?certificate_id=CERTIFICATE_ID
Request JSON body:
{ "lifetime": { "seconds": 3600, "nanos": 0 }, "pem_csr": "PEM_CSR" }
To send your request, expand one of these options:
You should receive a JSON response similar to the following:
{ "name": "projects/project-id/locations/location/certificateAuthorities/ca-id/certificates/certificate-id", "pemCertificate": "-----BEGIN CERTIFICATE-----...", "certificateDescription": {...} }
Request certificate using an auto-generated key
Console
You can use Google Cloud console to generate client or server TLS certificates.
Go to the Certificate Authority Service page on the Google Cloud console.
Click Request a certificate.
Select a region. The region must be the same as the region of the CA pool that you intend to use.
Select a CA pool.
Click Manually enter details. The certificate details are displayed.
Optional: Replace the auto-generated Certificate name with a custom name that is unique.
Optional: To choose a custom validity period for the certificate, enter the value in the Valid for field.
Add domain name
- Under Add domain name, enter a domain name in the Domain name 1 field.
- Optional: If you want to add more than one domain name, click Add item, and enter another domain name in the Domain name 2 field.
Extended key usage
Optional: Under Extended key usage, select between the following options based on your use case:
- Client TLS: These certificates let you authenticate the identity of a requester.
- Server TLS: These certificates let you authenticate the identity of a server.
Click Next.
Configure the key size and algorithm
- Optional: Under Configure key size and algorithm, select the signing key size and algorithm from the list. If you skip this step, RSASSA-PSS 2048 bit key with a SHA 256 digest is used. For information about selecting a signing key and algorithm, see Choose a key algorithm.
- Click Generate certificate.
Download the signed certificate
- To see the generated certificate, click View certificate, and then click View.
- Optional: To download the PEM-encoded certificate chain, click Download certificate chain.
Optional: To download the associated PEM-encoded private key, click Download private key.
gcloud
To use the auto-generated key feature, you need to install the Python Cryptographic Authority (PyCA) library. For instructions about installing the Pyca cryptography library, see Including the Pyca cryptography library.
To create a certificate, use the following gcloud
command:
gcloud privateca certificates create \
--issuer-pool POOL_ID \
--generate-key \
--key-output-file KEY_FILENAME \
--cert-output-file CERT_FILENAME \
--dns-san "DNS_NAME" \
--use-preset-profile "CERTIFICATE_PROFILE"
Replace the following:
- POOL_ID: The name of the CA pool.
- KEY_FILENAME: The path where the generated private key file must be written.
- CERT_FILENAME: The path where the PEM-encoded certificate chain file must be written. The certificate chain is ordered from end-entity to root.
- DNS_NAME: One or more comma-separated DNS subject alternative names (SANs).
- CERTIFICATE_PROFILE: The unique identifier of
the certificate profile.
For example, use
leaf_server_tls
for end-entity server TLS.
The gcloud
command mentions the following flags:
--generate-key
: Generates a new RSA-2048 private key on your machine.
You can also use any combination of the following flags:
--dns-san
: Lets you pass one or more comma-separated DNS SANs.--ip-san
: Lets you pass one or more comma-separated IP SANs.--uri-san
: Lets you pass one or more comma-separated URI SANs.--subject
: Lets you pass an X.501 name of the certificate subject.
For more information about the gcloud privateca certificates create
command, see gcloud privateca certificates create.
Go
To authenticate to CA Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To authenticate to CA Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to CA Service, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Request certificate using an existing Cloud KMS key
You can only use Google Cloud CLI to request certificates using a Cloud KMS key.
gcloud
To use a Cloud KMS key to create an end-entity server TLS certificate, run the following command:
gcloud privateca certificates create \
--issuer-pool POOL_ID \
--kms-key-version projects/PROJECT_ID/locations/LOCATION_ID/keyRings/KEY_RING/cryptoKeys/KEY/cryptoKeyVersions/KEY_VERSION \
--cert-output-file CERT_FILENAME \
--dns-san "DNS_NAME" \
--use-preset-profile "leaf_server_tls"
Replace the following:
- POOL_ID: The name of the CA pool.
- PROJECT_ID: The project ID.
- LOCATION_ID: The location of the key ring.
- KEY_RING: The name of the key ring where the key is located.
- KEY: The name of the key.
- KEY_VERSION: The version of the key.
- CERT_FILENAME: The path of the PEM-encoded certificate chain file. The certificate chain file is ordered from end-entity to root.
- DNS_NAME: Comma-separated DNS SANs.
Issue a certificate from a specific CA in a CA pool
This section describes how to issue certificates from a specific CA in a CA pool.
Console
Go to the Certificate Authority Service page on the Google Cloud console.
Click Request a certificate.
Select a region. The region must be the same as the region of the CA pool that you intend to use.
Select a CA pool.
To choose a CA, click Use a specific CA from this CA pool, and then select a CA from the list.
Select other parameters as you did in the Request certificate using an auto-generated Key section or the Request certificate using a CSR section.
gcloud
To target a specific CA in the CA pool for certificate issuance, add the
--ca
flag with the CA_ID of the CA that must issue the certificate.
gcloud privateca certificates create \
--issuer-pool POOL_ID \
--ca CA_ID \
--generate-key \
--key-output-file KEY_FILENAME \
--cert-output-file CERT_FILENAME \
--dns-san "DNS_NAME" \
--use-preset-profile "leaf_server_tls"
Terraform
Request a certificate in validation mode
Requesting a certificate in validation mode creates an unsigned test certificate. This test certificate is not PEM encoded and incurs no charge. While you can't download the certificate, the hypothetical certificate description lets you confirm that you can successfully issue a signed certificate with your chosen parameters.
To request a certificate in validation mode, follow these steps:
Console
Go to the Certificate Authority Service page on the Google Cloud console.
Click Request a certificate.
Select Use validation mode for a hypothetical certificate description instead of a signed certificate.
Follow the same steps as you would to request a signed certificate.
What's next
- Learn about certificate profiles.
- Learn how to revoke certificates.
- Learn how to sort and filter certificates.
- Learn how to manage certificates using the Google Cloud CLI.