Virtualization Pro

Nov 8 2007   5:19PM GMT

VI3 SDK – The Windows Hosts File

Kutz Profile: Akutz

Tags:
IMAP4

It seems to be a little known fact that Windows has a hosts file similar to the one found in Unix and Linux at /etc/hosts. In the case of Windows the file is found at %SystemRoot%\System32\Drivers\etc\hosts. The contents of the file look like this:


# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost

As you can, the Windows hosts file allows you to make arbitrary host name to internet protocol (IP) address assignments. Why am I telling you this? Because if you are programming with the VI3 SDK you may need to alter this file or have your application crash miserably:


Unhandled Exception: System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. --->System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

The above text is the error that occurs when you attempt to access the SDK’s web service with a host name that does not match what is on the SSL certificate that the SDK’s web server is using. By default the host name is “VMware”. So, if you have not changed the SSL certificate on the VirtualCenter server then you need to add a line to your Windows’ hosts file that points the host “VMware” (it is not case sensitive) to the IP address of your VirtualCenter server. Mine looks like this:


192.168.0.226 VMware

Voila! I can now access my VirtualCenter’s web server, and thus the VI3 SDK web service, programatically and without error.

Hope this helps!

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: