VMware – Replace the ESXi Certificate


KB ID 0000974 Dtd 24/07/14


ESXi comes with a self signed certificate, and for most people thats fine, but some clients want to have a 'Trusted' certificate on theirs, and have their own PKI infrastructure for issuing them.

Below I will generate a new certificate for my ESXi server using the Active Directory Certificate Services role on Windows Server 2012. Then replace the self signed certificate with my new one.


Generating a Certificate Request From the ESXi Server

1. Before we start there are a couple of hoops to jump through, and a Windows machine (it does not mater which one), install the following tow pieces of software;

Microsoft Visual C++ 2008 Redistributable Package (x86) and Shining Light Productions installer for OpenSSL x86 version 0.98r (or later)

Accept all the defaults and it should install to C:OpenSSL-Win32 go there, and in the bin directory make a backup of the openssl.cfg file.

Backup OpenSSL

2. Open the original openssl.cfg file and delete everything out of it, then paste in the following text, replace the values in red with your own, and save the file.

[ req ]
default_bits = 2048
default_keyfile = rui.key
distinguished_name = req_distinguished_name
encrypt_key = no
prompt = no
string_mask = nombstr
req_extensions = v3_req

[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth, clientAuth
subjectAltName = DNS:PNL-ESX1, IP:, DNS:PNL-ESX1.petenetlive.net

[ req_distinguished_name ]
countryName = GB
stateOrProvinceName = Teesside
localityName = Middlesbrough
0.organizationName = PeteNetLive
organizationalUnitName = Technical Services
commonName = PNL-ESX1.petenetlive.net

openssl.cfg file

3. Open a command window and execute the following three commands;

cd C:OpenSSL-Win32Bin
openssl req -new -nodes -out rui.csr -keyout rui-orig.key -config openssl.cfg
openssl rsa -in rui-orig.key -out rui.key

You will notice rui.csr has been created in the bin directory this is the file you need to request your certificate, if you open the file with Notepad you can copy the text.

ESX Create Certificate Request

Submit the Certificate Request and Get an ESX Certificate From a Windows CA

4. Open the web console of your certificate services server (it needs to be running the Certification Authority Web Enrollment role). The URL is usually http://{servers IP or Name}/Certsrv. Select 'Request a certificate'.

Request ESXi Certificates

5. Advanced certificate request.

Windows CA for ESX

6. Submit a certificate request by using a base-64-encoded CMC or PKCS #10 file, or submit a renewal request by using a base-64-encoded PKCS #7 file.

Replace ESXi Certificates

7. Paste in the text from your csr file (with no extra spaces!). Set the Certificate Template to 'Web Server' (the default lifetime for the Web Server template is 2 years. If you require longer, I suggest you clone the Web Server Template, change the lifetime and republish it in Active Directory Certificate Services).

ESX Web Server Certificate

8. Base 64 encoded> Download certificate.

Base 64 Certificate

9. Save the file as rui.cer and put it in the bin directory.

Replace ESXi Certificates

10. ESX needs the certificate to be in x509 format, so open a command window and execute the following commands;

cd C:OpenSSL-Win32bin
openssl x509 -in rui.cer -out rui.crt

Convert cer to crt

11. Enable SSH on your ESX Host.

Enale SSH on ESX

12. Connect to the ESX host via SSH, and make a backup of the current keys (just in case).

cd /etc/vmware/ssl
mv rui.crt backup.rui.crt

mv rui.key backup.rui.key

Backup ESX Certificates

13. Using WinSCP copy the rui.crt and the rui.key files from the bin directory, to the /etc/vmware/ssl directory on your ESX host. WARNING: Set the copy type to 'Text' or ASCII or you may get some strange results.

Replace ESX CErtificates with WinSCP

14. Then either restart the management agents, or from your SSH session execute the following command;

/sbin/services.sh restart

ESX restart SSH

15. The simplest way to check is browse to the FQDN or your ESX host (the same name you used as the common name in step 2), and take a look at the certificate.

Replace ESXi Certificates

Related Articles, References, Credits, or External Links


Author: Migrated

Share This Post On