WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Retrieving vCenter Server certificate (Machine, VMCA Root, STS & Trusted Root) details using the vSphere API 

Retrieving vCenter Server certificate (Machine, VMCA Root, STS & Trusted Root) details using the vSphere API 

09.11.2023 by William Lam // 11 Comments

In the vSphere UI, users can easily view and manage all of their vCenter Server certificates by navigating to Administration->Certificate->Certificate Management as shown in the screenshot below.


There are four types of vCenter Server certificates: Machine SSL, VMware Certificate Authority, STS Signing Certificate and the Trusted Root. On the main summary view, we can see the validity of the certificate, which is useful to quickly determine if you need to plan on replacing a specific certificate. We can also get more information about a specific certificate by clicking on the "View Details".

A question recently came up internally asking whether there is a vSphere API to retrieve all of this information programmatically, especially the validity of the certificate?

The answer is yes! All certificate management functionality in vCenter Server is also available using the vCenter REST API also referred to as vSphere Automation API. Below are the specific APIs for retrieving each type of certificate:

  • Machine SSL Certificate
    • https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/certificate-management/vcenter/tls/get/
  • VMware Certificate Authority & STS Signing Certificate
    • https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/certificate-management/vcenter/signing-certificate/get/
  • Trusted Root
    • https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/certificate_management/vcenter.trusted_root_chains/

To demonstrate the certificate management API, I have created a quick PowerCLI function called Get-VCSACertificate that makes it super easy to retrieve either all or a specific certificate.

Step 1 - Download the Get-VCSACertificate.ps1 to your local system

Step 2 - Source the Get-VCSACertificate.ps1 file which contains the PowerCLI Get-VCSACertificate function by running the following command:

. ./Get-VCSACertificate.ps1

Step 3 - Connect to vCenter Server using the Connect-CisServer cmdlet since we are interacting with the vCenter REST API

Connect-CisServer -Server vc.primp-industries.local -User administrator[at]vsphere[dot]local -Password VMware1!

Step 4 - Run the Get-VCSACertificate function without any arguments to retrieve all vCenter Server certificates:

Get-VCSACertificate


You can also filter for a specific certificate type by using the -Type argument which supports the following values: MACHINE, VMCA_ROOT, STS and TRUSTED_ROOT which you can see some examples below:

Get-VCSACertificate -Type STS
Get-VCSACertificate -Type VMCA_ROOT

More from my site

  • Is vCenter Server & ESXi hosts using VMware Certificate Authority (VMCA) or custom CA certificates?
  • Automating Customer Experience Improvement Program (CEIP) configuration using vSphere API and PowerCLI
  • Instant Clone Microsoft Windows & VM Keystroke VMworld demo and code posted
  • Retrieving detailed per-VM space utilization on VSAN
  • Quick Tip - How do I tell if NSX-V or NSX-T is installed?

Categories // Automation, PowerCLI, vSphere Tags // PowerCLI, STS, TLS, VMCA, vSphere API

Comments

  1. *protectedJeff says

    09/11/2023 at 9:03 am

    When is VMware going to support the ACME for automated 3rd party CA renewals? With Google pushing 30 day SSL lifetimes this is imperative.

    Reply
  2. *protectedAnonymous says

    09/11/2023 at 12:18 pm

    Is there any news about the vCert tool from GSS?

    Reply
  3. *protectedHob says

    09/12/2023 at 8:35 pm

    Is it possible to retrieve the Solution User certificates using the REST API?

    Reply
    • William Lam says

      09/14/2023 at 7:53 am

      No, since they've been deprecated since 7.x https://blogs.vmware.com/vsphere/2020/04/vsphere-7-certificate-management.html

      Reply
  4. *protectedJeff Wu says

    01/08/2024 at 12:31 am

    Please tell me, when I run the Get-VCSA Certificate.ps1 script, it will appear [System.Security.Cryptography.X509Certificates.X509Certificate2] does not contain a method named 'CreateFromPem'.

    Reply
    • *protectedRA says

      01/08/2024 at 9:41 am

      Same here, tried from Windows PowerCLI and also from a Linux box, no luck!

      Reply
      • *protectedMario Ayuga says

        02/05/2024 at 4:56 am

        I have the same problem, X509Certificate2 does not contain a method name CreateFromPem.

        I tried $Cert2Type:: and tab, and only shows:

        CreateFromCertFile
        CreateFromSignedFile
        Equals
        GetCertContentType
        new
        ReferenceEquals

        Reply
        • *protectedMario Ayuga says

          02/05/2024 at 5:36 am

          I think the problem is I'm using Powershell ISE and it only works until PowerShell V5.1. I tried in a simple PowerShell 7 windows and I have all the method, I will migrate to Visual Studio Code from ISE.

          Reply
    • *protectedAlek says

      10/28/2024 at 8:59 am

      You can adjust the script like this (to use a temporary file)

      $env:TMP='c:\temp'
      foreach ($signingCert in $signingCerts) {
      $signingCert | Set-content $env:TMP\cert.crt
      $cert = $xCert2Type::CreateFromCertFile("$env:TMP\cert.crt") -as $xCert2Type

      BR, Alek

      Reply
  5. *protectedChris Leblanc says

    04/02/2024 at 6:03 pm

    I'm trying to figure out how to make this work with a user that is not admin. I hope there is a group I can add my report account to but no luck so far.

    Reply
  6. *protectedHardy Ruoss says

    02/23/2025 at 11:36 pm

    Hi William, i am facing the problem that i have expired STS certs on a vcenter 6.0.xx on windows and the standard cert manager is alsways failing to do so. is there any chance that i can replace the sts certs by hand. or can you maybe help me with this ? of course not for free .....
    thanks for a feedback anyway .....

    Reply

Leave a Reply to RACancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...