A Little Known Security Feature in vCenter: Certificate Based Authentication

Although we are all familiar with the username and password based login to the VMware vSphere, it’s also possible to login into vSphere with just certificates. If you are a third party vendor, either IHV (independent hardware vendor) or ISV (independent software vendor), the certificate based login is actually a better and preferred alternative to the one using username and password.

Let me explain why it’s the case, and how it can be done painlessly.

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure

First, why certificate is a better option than the username and password?

The certificates offer stronger security than the username and password. For one thing, a password can easily be stolen by a simple glimpse. Not so easily with a certificate which is full of hex digits and way too long for anyone to memorize.

It’s not a good idea to save password with your application, but quite some applications do this anyway. Even worse is that most saved credentials are for the root users. Not because anyone wants to have an insecure product, but for convenience so that users are not required to enter password again and again.

The password for vCenter can change over the time and obsolete the old password. That means your application has to update the password accordingly as well, or it will break. It won’t be a problem for the certificate. Once you have it registered with the vCenter, it will continue to work with the vCenter forever. That is a big plus from maintenance point of view.

With these in mind, I think every customer should ask for certificate based authentication with any third party server applications for better security and easy maintenance. For VMware partners, you may want to seriously consider to leverage this feature in vCenter.

Upon this point, I hope we all agree that is the direction to go. Now let’s take a look at how to do it with the vSphere APIs. This is going to be a bit techy so bear with me for that.

Before we digging down to the code, let’s be clear that he certificate login only work with vCenter servers, not the ESXi servers. For the very first time, the username and password are still needed so that the registration of the certificate can be done. For the logins to the vSphere afterwards, the same certificate is needed.

The following are the code snippets illustrating how you can use certificate to authenticate with vCenter using vijavaNG:

After the ServiceInstance object is created, you can use it no different from similar one created using username and password. Note that the way how the vCenter handles it is via SDK tunnel with HTTP. This is a pretty complicated topic that deserves its own post.

NEED HELP?

My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.