Leo’s Ramblings Rotating Header Image

VirtualCenter CA Configuration – take 3

Updated: Thanks to Geert Baeke (in comments) for noticing my error – when creating a .pfx certificate file it is important to set the password as testpassword, otherwise sysprep encrypted passwords in your customization scripts will not work. The relevant sections has been modified. You learn something new every day

:)

In the comments of the first article on the matter, Trevor said that he was getting a .pfx file of length 0KB.

I can confirm that I am reproducing the same issue – and it seems to be with a bug in the openssl compiled by the third party.

Here’s how to do it another way if the same problem occurs to you.

Obviously if the links expire, the versions are too old – just browse to the base FQDNs in the links and download the latest version of the software available.

  • Edit the ca.pl file in C:\OpenSSL\bin so that this line:

$DAYS="-days 365"; # 1 year

is transformed to this:

$DAYS="-days 3650"; # 10 years

  • Edit the openssl.cfg in C:\OpenSSL\bin by making the following changes:

default_days = 365 # how long to certify for

to

default_days = 3650 # how long to certify for

and add the bold text in the correct areas as referenced by the non-bold text:

stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = NSW

localityName = Locality Name (eg, city)
localityName_default = Kingsford

0.organizationName = Organization Name (eg, company)
0.organizationName_default = Private Company

organizationalUnitName = Organizational Unit Name (eg, section)
organizationalUnitName_default = IT&T

emailAddress = Email Address
emailAddress_max = 64
emailAddress_default = raikhman@gmail.com

Also, make sure to edit to the correct values, all above settings that are boldened and italicised.

  • Copy ca.pland openssl.cfg from C:\OpenSSL\bin to C:\Program Files\GnuWin32\bin
  • Open a command prompt and cd to C:\OpenSSL\bin
  • Run: C:\perl\bin\perl ca.pl -newca. When requested for the common name, just punch in “server”
  • Copy the resulting C:\OpenSSL\bin\demoCA directory to C:\Program Files\GnuWin32\bin
  • Uninstall OpenSSL (the one in Add/Remove Programs without a GnuWin32 moniker)
  • Use the same command prompt that is still open and cd to C:\Program Files\GnuWin32\bin
  • Run: openssl genrsa 1024 > rui.key
  • Run: openssl req -new -key rui.key > rui.csr -config openssl.cfg. When it asks for the common name, type in the FQDN of the VirtualCenter server (eg. auconvc01.contoso.com.au)
  • Run: openssl ca -out rui.crt -config openssl.cfg -infiles rui.csr
  • Run: openssl pkcs12 -export -in rui.crt -inkey rui.key -name rui -passout pass:testpassword -out rui.pfx

At this point, you’ve created 3 files – rui.key, rui.crt and rui.pfx

Go into C:\Documents and Settings\All Users\Application Data\VMware\Infrastructure\VMware VirtualCenter Server\ and rename the SSL directory to SSL.old. Then create a directory called SSL. Copy the created files into this directory.

Next, open up the Microsoft Management Console (Start -> Run -> MMC) and open up the snap-in for Computer Account Certificates. Import the rui.crt certificate file into the Trusted Publishers container.

CD in the command prompt to the VMware VirtualCenter Server install directory and run vpxd -p. This will re-initialise the database on your SQL server with the new certificate. You will be asked for the DB password – input it.

Restart the VirtualCenter Service.

The problem is that now the ESX hosts don’t have the right certificate and are unable to communicate. Just disconnect them and reconnect them to re-enable HA/DRS/VMotion functionality.

All done :)

11 Comments

  1. YTACC says:

    Hi,

    I am getting error

    C:\Program Files\VMware\Infrastructure\VirtualCenter Server>vpxd -p
    [2008-08-28 06:41:23.878 'App' 5256 info] Current working directory: C:\Program
    Files\VMware\Infrastructure\VirtualCenter Server
    [2008-08-28 06:41:23.878 'BaseLibs' 5256 info] HOSTINFO: Seeing AMD CPU, numCore
    sPerCPU 2 numThreadsPerCore 1.
    [2008-08-28 06:41:23.878 'BaseLibs' 5256 info] HOSTINFO: This machine has 2 phys
    ical CPUS, 4 total cores, and 4 logical CPUs.
    [2008-08-28 06:41:23.878 'App' 5256 info] Log path: C:\Documents and Settings\Al
    l Users\Application Data\VMware\VMware VirtualCenter\Logs
    [2008-08-28 06:41:23.878 'App' 5256 info] Initializing SSL
    [2008-08-28 06:41:23.878 'BaseLibs' 5256 info] Using system libcrypto, version 9
    0709F
    [2008-08-28 06:41:25.176 'App' 5256 info] Vmacore::InitSSL: doVersionCheck = tru
    e, handshakeTimeoutUs = 120000000
    [2008-08-28 06:41:25.176 'App' 5256 error] [VpxdCertificate] Failed: unrecognize
    d file format: C:\Documents and Settings\All Users\Application Data\VMware\VMwar
    e VirtualCenter\ssl\rui.crt
    [2008-08-28 06:41:25.176 'App' 5256 error] Failed to load certificates

    C:\Program Files\VMware\Infrastructure\VirtualCenter Server>

    Regards,
    TYACC

  2. Leo says:

    That’s very interesting. When I do a “vpxd -p” I don’t see my CPU listing.

    Let me check this again tomorrow, and I’ll let you know.

  3. [...] In the earlier post, I mentioned VMware’s PDF as a good starting point for the certificate renewal process. The PDF explains a lot of different things, but leaves a few key areas out about how to fix the immediate problem. Luckily, I came across a very handy blog that simplifies things and gave me easy steps to follow. Leo Raikhman’s Ramblings blog gives direct guidance for those of us who are a little fuzzy with certificates. Leo points out in three separate blogs a basic way to address the problem, a 1-2-3 approach, and some in-depth explanation for an occasional zero-length pfx file causing generation issues. [...]

  4. YTACC says:

    Hi All,
    The problem is with certifcation format generation, i have solved the issue, thanks for your support

    Cheers
    Y

  5. ByronZ says:

    I followed this instruction to create the new self-signed certificate successfully. However, I still got the Security Alert when I connect to it. Am I missing anything?

    Thanks
    BZ

  6. Leo says:

    Hi BZ,

    Yes, just because you create a certificate doesn’t mean you trust it’s root, similar to how you browse SSL sites which haven’t got a CA-signed cert.

    What you need to do is adjust GPO to authorize the CA root for your domain.

  7. ByronZ says:

    Leo,

    I manually installed the cert to Trusted Root Certification Authorities already. But still getting the error…

    BZ

  8. Leo says:

    Interesting…

    I used this guide (the latter part).

    See if that works for you…

    Cheers,
    Leo

  9. ByronZ says:

    Leo,

    I think it is that particular machine has problems with CA. When I tried it on another machine, it is working fine. Thanks a lot for your help.

    BZ

  10. Moolovows says:

    so what do you think?

Leave a Reply