Create a Certificate using a Certificate Authority
Stay organized with collections
Save and categorize content based on your preferences.
Use a created Certificate Authority to issue a certificate
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# Create a Certificate using a Certificate Authority\n\nUse a created Certificate Authority to issue a certificate\n\nCode sample\n-----------\n\n### Terraform\n\n\nTo learn how to apply or remove a Terraform configuration, see\n[Basic Terraform commands](/docs/terraform/basic-commands).\n\n\nFor more information, see the\n[Terraform provider reference documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs).\n\n resource \"google_privateca_certificate_authority\" \"test_ca\" {\n certificate_authority_id = \"my-example-certificate-authority\"\n location = \"us-central1\"\n pool = \"my-pool\"\n ignore_active_certificates_on_deletion = true\n deletion_protection = false # set to true to prevent destruction of the resource\n config {\n subject_config {\n subject {\n organization = \"HashiCorp\"\n common_name = \"my-certificate-authority\"\n }\n subject_alt_name {\n dns_names = [\"hashicorp.com\"]\n }\n }\n x509_config {\n ca_options {\n is_ca = true\n }\n key_usage {\n base_key_usage {\n cert_sign = true\n crl_sign = true\n }\n extended_key_usage {\n server_auth = true\n }\n }\n }\n }\n key_spec {\n algorithm = \"RSA_PKCS1_4096_SHA256\"\n }\n }\n\n resource \"google_privateca_certificate\" \"default\" {\n pool = \"my-pool\"\n location = \"us-central1\"\n certificate_authority = google_privateca_certificate_authority.test_ca.certificate_authority_id\n lifetime = \"860s\"\n name = \"my-example-certificate\"\n config {\n subject_config {\n subject {\n common_name = \"san1.example.com\"\n country_code = \"us\"\n organization = \"google\"\n organizational_unit = \"enterprise\"\n locality = \"mountain view\"\n province = \"california\"\n street_address = \"1600 amphitheatre parkway\"\n }\n subject_alt_name {\n email_addresses = [\"email@example.com\"]\n ip_addresses = [\"127.0.0.1\"]\n uris = [\"http://www.ietf.org/rfc/rfc3986.txt\"]\n }\n }\n x509_config {\n ca_options {\n is_ca = false\n }\n key_usage {\n base_key_usage {\n crl_sign = false\n decipher_only = false\n }\n extended_key_usage {\n server_auth = false\n }\n }\n }\n public_key {\n format = \"PEM\"\n key = base64encode(data.tls_public_key.example.public_key_pem)\n }\n }\n }\n\n resource \"tls_private_key\" \"example\" {\n algorithm = \"RSA\"\n }\n\n data \"tls_public_key\" \"example\" {\n private_key_pem = tls_private_key.example.private_key_pem\n }\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=privateca)."]]