Skip to content

RootCAProvider certificate validation fails if default interface has multiple IP addresses #2877

Closed

Description

@csquire
ISSUE TYPE
  • Bug Report
COMPONENT NAME
CA
CLOUDSTACK VERSION
4.11.1.0
CONFIGURATION

Two management servers using a VIP and UCARP for failover.

OS / ENVIRONMENT

N/A

SUMMARY

Secure connections between two management servers using the default root CA provider don't pass validation if the default interface has multiple IP addresses.

For example, using a Virtual IP with UCARP for management server failover, the default interface on the primary management server will have two IP addresses assigned. The Cloudstack RootCAProvider generates certificates by using one IP address from the default interface and including it in the certificate as a SAN (from my experience, the Virtual IP is put in the certificate). When the primary management server attempts connection to the secondary management server, the connection is rejected because the secondary server determines the connection to be from the 'real' IP address of the primary server and cannot validate the certificate because only the Virtual IP is listed as a SAN.

STEPS TO REPRODUCE
Example:
Let's say we have the following:
primary server's IP is 192.168.1.10 and Virtual IP is 192.168.1.20

The certificate is generated with 192.168.1.20 as a SAN.
The secondary server attempts to validate a connection from the primary. The connection is from 192.168.1.10, 
so it can't validate the certificate presented by the primary controller.

In the logs you can find the following:
Certificate ownership verification failed for client: 192.168.1.10

A client/agent attempting connection from address=192.168.1.10 has presented these certificate(s):
Certificate [1] :
Serial: xxx
Not Before:Wed Oct 03 04:29:46 UTC 2018
Not After:Fri Sep 25 16:29:46 UTC 2048
Signature Algorithm:SHA256withRSA
Version:3
Subject DN:CN=cloudstack1.example.com
Issuer DN:CN=ca.cloudstack.apache.org
Alternative Names:[[7, 192.168.1.20], [2, cloudstack1.example.com]]
Certificate [2] :
Serial: xxx
Not Before:Mon Aug 20 05:27:08 UTC 2018
Not After:Wed Aug 12 17:27:08 UTC 2048
Signature Algorithm:SHA256withRSA
Version:3
Subject DN:CN=ca.cloudstack.apache.org
Issuer DN:CN=ca.cloudstack.apache.org
Alternative Names:null
EXPECTED RESULTS
I would expect all IP addresses for the default interface to be included as Subject Alternative Names in the certificate.
ACTUAL RESULTS
Only the Virtual IP is included in the certificate as a Subject Alternative Name on the primary controller and connection to the secondary controller fails validation.

Activity

  1. added this to the 4.11.2.0 milestone on Oct 4, 2018
  2. yadvr commented on Oct 4, 2018

    @yadvr
    Member

    @csquire the setup you've described is a specific one, I'll see if we can modify the code that instantiates the management server certificate on startup to scan and include all the ips addresses on the management server host.

  3. self-assigned this
    on Oct 4, 2018
  4. added a commit that references this issue on Oct 5, 2018
    3fd8bd3
  5. yadvr commented on Oct 5, 2018

    @yadvr
    Member

    @csquire can you review/test this PR: #2879

  6. csquire commented on Oct 5, 2018

    @csquire
    ContributorAuthor

    @rhtyd thanks, that was quick! I had actually patched our test system by adding a custom CA provider as a plugin with the same approach and it worked well. I was going to submit a PR, but you beat me to it. Anyways, I copied your new NetUtils.getAllDefaultNicIps() method to my plugin and quickly deployed it and it works well. The only difference I noticed is that yours places the IPV6 address in the certificate (in addition to both IPV4 addresses) where my implementation did not. So, LGTM. :-)

  7. yadvr commented on Oct 5, 2018

    @yadvr
    Member

    Great, thanks for confirming and testing @csquire

  8. added a commit that references this issue on Oct 7, 2018
    f430f41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions