Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Certificate Manager
  • Getting started
    • All guides
      • Adding a certificate
      • Getting the contents of a certificate
      • Domain rights check procedure
      • Renewing a certificate
      • Editing a certificate
      • Deleting a certificate
    • Backups
    • Adding alerts for certificates
    • Configuring access to a certificate
    • Viewing operations with a certificate
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Certificate from Let's Encrypt
  3. Getting the contents of a certificate

Get the contents of the Let's Encrypt certificate

Written by
Yandex Cloud
Updated at April 22, 2025

You can save a certificate chain and a private key to use on your own, e.g., when configuring a web server on a VM.

To get the contents of a certificate:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where the certificate is located.

  2. From the list of services, select Certificate Manager.

  3. Next to the certificate, click and select Export certificate.

    You can only export certificates with the Issued status.

  4. Select one of the export options. The certificate.pem file will contain the following data in Base64 encoded text format:

    • End-entity certificate and chain: Certificate chain (root and target certificate) and private key with standard framing:

      -----BEGIN CERTIFICATE-----
      MIIE5zCCA8+gAwI...
      -----END CERTIFICATE-----
      -----BEGIN CERTIFICATE-----
      MIIFFjCCAv6gAwIBAg...
      -----END CERTIFICATE-----
      -----BEGIN PRIVATE KEY-----
      MIIEvgIBADANBgk...
      -----END PRIVATE KEY-----
      
    • Certificate without private key: Certificate chain (root and target certificate):

       -----BEGIN CERTIFICATE-----
       MIIE5zCCA8+gAwI...
       -----END CERTIFICATE-----
       -----BEGIN CERTIFICATE-----
       MIIFFjCCAv6gAwIBAg...
       -----END CERTIFICATE-----
      
    • End-entity certificate:

      -----BEGIN CERTIFICATE-----
      MIIFFjCCAv6gAwIBAg...
      -----END CERTIFICATE-----`
      
    • Private key only:

      -----BEGIN PRIVATE KEY-----
      MIIEvgIBADANBgk...
      -----END PRIVATE KEY-----`
      
  5. Click Download certificate.

The command will display a certificate chain and a private key and save their contents to the --chain and --key files, respectively.

  • --id: Certificate ID; make sure you set either the --id or --name flag.
  • --name: Certificate name; make sure you set either the --id or --name flag.
  • --chain: (Optional) File to save the certificate chain to in PEM format.
  • --key: (Optional) File to save the private key to, in PEM format.
yc certificate-manager certificate content \
  --id fpqcsmn76v82******** \
  --chain certificate_full_chain.pem \
  --key private_key.pem

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

To get the contents of a custom certificate using Terraform:

  1. In the Terraform configuration file, define the parameters of the resources you want to create:

    data "yandex_cm_certificate_content" "cert_by_id" {
      certificate_id = "<certificate_ID>"
    }
    
    output "certificate_chain" {
      value = data.yandex_cm_certificate_content.cert_by_id.certificates
    }
    
    output "certificate_key" {
      value     = data.yandex_cm_certificate_content.cert_by_id.private_key
      sensitive = true
    }
    

    Where:

    • data "yandex_cm_certificate_content": Description of the data source for the certificate contents:
      • certificate_id: Certificate ID.
    • output sections: certificate_chain output variables with a certificate chain and a certificate_key private key:
      • value: Returned value.
      • sensitive: Label data as sensitive.

    For more information about the yandex_cm_certificate_content data source parameters, see the provider documentation.

  2. Create the resources:

    1. In the terminal, change to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. Run the command:

      terraform plan
      

      The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

    4. Apply the configuration changes:

      terraform apply
      
    5. Confirm the changes: type yes in the terminal and press Enter.

    Terraform will create all the required resources. To check the results, run these commands:

    • Get a certificate chain:

      terraform output certificate_chain
      
    • Get the private key value:

      terraform output -raw certificate_key
      

To get the certificate contents, use the get REST API method for the CertificateContent resource or the CertificateContentService/Get gRPC API call.

Note

To view the certificate contents, assign the certificate-manager.certificates.downloader role to the service account.

Was the article helpful?

Previous
Adding a certificate
Next
Domain rights check procedure
Yandex project
© 2025 Yandex.Cloud LLC