If you’re like me, you are annoyed by the message warning that the certificate being presented by your vCenter machine is “untrusted.” Yeah, you all know the one I mean:
A little bit of OCD?
For me, I don’t like to just check the box at the bottom and pretend it doesn’t exist. Aside from the fact that the checkbox doesn’t always make the messages cease, I like to have a real solution instead of sweeping it under the rug. When you think about it, the team at VMware implemented certificates for a reason. I’m sure it had mostly to do with encrypting the connection between vSphere clients, vCenter and the hosts, but those scary certificate things can do more, too!
Prerequisites
In this posting, I will focus on the VMware vCenter Management Appliance (VCMA) since the process for getting certificates registered on that appliance has been difficult to find. If you want to know how to do it for ‘regular’ (i.e. Windows-based) vCenter, or the ESXi hosts, I think the processes are documented in the vSphere Security Guide – check Chapter 5 for more information. (The actual generation of the key and CSR files and retrieval of the certificates follows the same process I outline here, but you push the files to the ESXi hosts to replace the rui.key and rui.crt files in the /etc/vmware/ssl directory.)
Also, for the sake of this posting, I will assume that you have some form of public key infrastructure (PKI) in place – that would be a certificate infrastructure used at your company – and the capability to have a server authentication-type certificate request fulfilled. These certificates are commonly used by web servers, so being able to do that is probably a good indication that you can get the appropriate certificates created. Creating a PKI just to make the warnings go away is a little crazy and actually does your environment a disservice: the CA needs to be a trusted authority within your organization and should be designed accordingly rather than stood up in an hour. If you pay for all of your certificates to be issued from a public CA, that’s fine as well.
Getting off my soapbox and back to the task at hand, let’s make sure you have the following in your environment:
- A vCenter Management appliance deployed on top of an ESXi host – it will run under Workstation 8. I haven’t tried previous versions, but this works if you want to play around.
- puTTY, or your favorite SSH client – I like accessing the VCMA via SSH so I can paste the long commands into the console.
- Some way to transfer the CSR and CER files to/from the VCMA. Technically, you can copy and paste the text using puTTY, but I use FileZilla in my example.
- A vSphere client installed
- A compatible web browser
- A properly functioning PKI, public key (certificate) infrastructure, is currently in place
High Level Overview
- Deploy the VCMA from the OVF
- Configure some initial parameters within the VCMA’s Linux OS
- Create a certificate request (CSR) on the VCMA
- Submit the CSR to the certificate authority (CA)
- Apply the resulting certificate to the VCMA
This should be simple, right?
Arrival
I am assuming that step #1 has been completed. It is best if you start with a fresh, clean VCMA in order to ensure that the process works. Once your database has been populated, I think the process works, but I don’t know if there are any snags – caveat emptor.
2. Configure some initial parameters within the VCMA’s Linux OS
Set Hostname
In my testing, I’ve found that it is helpful to set the hostname and ensure name resolution on the VCMA prior to messing with anything else. From the console of the VCMA, select the Login option and login as the root user (default username is root and the password is vmware – at least as of build 472350).
This is a good time to present my hostname and IP address — I’ll use these throughout the example.
- VCMA Hostname: vcma01
- VCMA Domain: itplab.local
- VCMA FQDN: vcma01.itplab.local
- VCMA IP Address: 192.168.199.128
Once logged in on the console as root, set the hostname and activate the change
# echo vcma01.itplab.local >/etc/HOSTNAME
# hostname –file /etc/HOSTNAME
Once that is done, logout and back in to make sure the prompt changes appropriately. On the console, this looks something like the following:
I make a KEYS directory in the root user’s home directory to contain the files I’ll be using here. Feel free to do so, or not, but my examples assume this setup.
# mkdir KEYS
Name resolution
I always forget to do this, but if you don’t have DNS resolution configured, either do that or append a line to your /etc/hosts file to provide name resolution.
# echo 192.168.199.128 vcma01.itplab.local vcma01 >>/etc/hosts
I like to test pinging by name to ensure that I didn’t make a mistake.
3. Creating a Certificate Signing Request (CSR) on the VCMA
Now back to our regularly scheduled program. Switch to the KEYS directory and create the CSR.
# cd KEYS
# openssl req -out vcma01.csr -new -newkey rsa:2048 -nodes -keyout vcma01.key
Walk through the process, answering the questions as they apply to you. Be careful to answer the Common Name (eg, YOUR name) prompt with the FQDN of the VCMA, not YOUR name.
..continued
Transfer the Certificate Signing Request (CSR) to the Certificate Authority (CA)
Once the CSR has been generated according to the process above, there will be two new files in your directory: a .csr file and a .key file.
You need to get the CSR file’s contents to your CA to request and create the certificate. FileZilla is a free way to do this using the already-running SSH process on the VCMA. Provide the IP address or hostname, credentials, and port number for the connection (22):
Accept the SSH key for the connection — if you don’t check the box, it will only accept the key for this session.
If you like, you can verify the fingerprint from the command line of the VCMA:
# ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub
Just check that the resulting fingerprint matches the one in the FileZilla box above and you’re good.
FileZilla presents a simple two-pane file manager – the VCMA is on the right and your local machine is on the left. Navigate to the KEYS directory on the VCMA and pull the vcma01.csr file to your machine: drag it from the right pane into the left pane and wait for the transfer.
In the example, I got a little crazy with the mouse and copied both files – you only need the CSR.
4. Requesting the Certificate
In my environment, we have a Microsoft Windows Certificate Server deployed, so this process uses that infrastructure.
Browse to the web portal for the CA by using the proper URL.
This displays the following Welcome page. Note that you may need to authenticate before it gets there.
Click on the Request a certificate link in the Select a task list.
Depending on your access to the CA and the types of certificates it has been enabled to deploy, you may see different options here. Regardless, you want to click on the advanced certificate request link.
Since we have already generated the certificate request (CSR), we want the second option here. Don’t worry, even though the link text is longer, it means fewer boxes for us to fill out. Here, you want to select the Web Server certificate type from the Certificate Template drop-down. If that certificate type is not in the list, your CA Administrator may have disabled it, or you may not be authorized to create that type – you’ll need to contact the appropriate person to get that resolved.
Open the CSR file from the VCMA in Wordpad, Notepad, or your favorite text editor, copy the entire contents – be sure to include the
-----BEGIN CERTIFICATE REQUEST-----
and
-----END CERTIFICATE REQUEST-----
lines.
…and paste it into the Saved Request box:
When you click Submit, the certificate request process implemented in your environment is set in motion. If certificates require approval, you’ll have to get that process completed and come back once it is done. Otherwise, the next screen will be presented.
Be sure to change the radio button from DER encoded to Base 64 encoded before continuing. It just makes the process simpler. Once that is done, click the Download certificate link and save the file somewhere that makes sense to you, and with a name that is easy to type. I tend to use the VCMA’s hostname to keep things simple.
NOTE: In our lab environment, the root CA actually issues our certificates. If you’ve got a mature or large PKI, there is normally an intermediate issuing CA that you’re accessing, and you may need to download the whole chain. My assumption here is that your root and any intermediate CAs are already trusted by your client – i.e., your PKI is properly in place.
Once the certificate has been created and saved, use FileZilla to push the file onto the VCMA using the reverse of the process you used to download the CSR.
Checking the Certificate
From the VCMA CLI, verify that the files are where you think they are.
I always check the fingerprint of my certificates so I know which ones I’m replacing and which ones I’m installing. An added benefit is that it ensures a proper transfer occurred:
# /usr/bin/openssl x509 -fingerprint -noout -in vcma01.cer
Aside: DOS line endings
One thing I noticed was that CER files from DOS machines came across with CR/LF line endings that tend to muck things up in Linux – when it comes to certificate files and keys, at least. I realize that you can take care of this in a variety of ways – use your favorite method.
To see what I mean, use the vi editor to open the certificate
If you look at the bottom line (highlighted in red in the above image), it contains the filename in double quotes followed by [dos]. This means that the file contains CR/LF line endings used by DOS and Windows operating systems. It may not seem like a big deal, but those hidden extras can bite you.
For fixing things up, I like awk. With a simple command, you can replace all that DOS/Windows nastiness with *nix goodness:
# awk '{sub (/\r$/,"");print}' vcma01.cer >vcma01.crt
Check the new file with vi and notice that the [dos] is gone. Notice that I fixed the file into a new file rather than clobbering the original. We’ll deal with the .crt file from this point forward.
Configure the VCMA
Accept the EULA
Before you can do anything useful with the VCMA, you must accept the EULA. You can do that via the web interface of the VCMA https://YOUR_VCMA_IP_ADDRESS:5480, or from the command line. We’re already there, so I use that. If you prefer to click rather than type, go nuts. I’ll wait while your web browser loads the UI and you login.
# vpxd_servicecfg eula accept
Accepting the EULA does all kinds of things for us, but the most important part is the VC_CFG_RESULT=0 line at the end. That indicates that our vpxd_servicecfg command was successful. Don’t worry about any of the other red or yellow stuff at this point.
Initialize the Database
Why do you have to configure the database now? Well, if you don’t, the certificate swapping function in vpxd_servicecfg fails. Beyond that, I have no idea. In this example, I’m using the embedded database. You can use an external database and configure it via the command line as well, but I don’t have an external Oracle DB in my test environment.
# vpxd_servicecfg db write embedded
See those Host name lookup failure lines? As I mentioned before, I’d forgotten to configure name resolution during this run. Don’t worry, the database initialized fine. Be warned, however, that this can take a long time if you’re doing it against slow storage. As before, the important line is the VC_CFG_RESULT=0.
As I mentioned before, I’m big into checking certificate thumbprints. The first two keys’ fingerprints should match, but will be different from the one you want to install (the third one):
# /usr/bin/openssl x509 –fingerprint –noout –in /opt/vmware/etc/lighttpd/server.pem
# /usr/bin/openssl x509 –fingerprint –noout –in /opt/vmware-vpx/ssl/rui.crt
# /usr/bin/openssl x509 –fingerprint –noout –in ~/KEYS/vcma01.crt
Making the certificate swap is accomplished with a single command
# vpxd_servicecfg certificate change vcma01.crt vcma01.key
Note that you will get an error, VC_CFG_RESULT=653, if you were jumping ahead (as in the following picture) and got the service started before we got the certificates swapped.
The following command will take care of that so you can get back on track:
# service vmware-vpxd stop
When all goes as planned, you get the VC_CFG_RESULT=0
Re-checking the fingerprints of the same files as before, we see that they all match, indicating that the certificate swap was a success.
# /usr/bin/openssl x509 –fingerprint –noout –in /opt/vmware/etc/lighttpd/server.pem
# /usr/bin/openssl x509 –fingerprint –noout –in /opt/vmware-vpx/ssl/rui.crt
# /usr/bin/openssl x509 –fingerprint –noout –in ~/KEYS/vcma01.crt
Go ahead and login to the VCMA with your vSphere client and you should no longer receive a certificate warning.
NOTE: I have noticed that the vSphere Web Client on the VCMA (https://YOUR_VCMA_IP_ADDRESS:9443/vsphere-client/) appears to use a different certificate.
That will have to wait for another blog post…
{ 0 comments }





















