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.

Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.

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:

    char[] password = "doublecloud".toCharArray();
    InputStream is = KeyMgrFactoryUtil.getStreamFromJar("mykeystore.jks");
    kmFactory = KeyMgrFactoryUtil.createKeyMgrFactory(is, password);
 
    Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(“vc.doublecloud.net, 80));
    serviceInstance = new ServiceInstance(new URL(SDK_TUNNEL_URI), extKey, true, ServiceInstance.VIM25_NAMESPACE, kmFactory, proxy);
...

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.

This entry was posted in vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • 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.