Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure external certs have a hash #3535

Merged

Conversation

rene-dekker
Copy link
Member

@rene-dekker rene-dekker commented Oct 10, 2024

Related to #3503 and #3532

Users may use the same cert for both Kibana and ES. This causes pod restarts, because deployments may get a hash for Kibana OR ES and not both. This change will render both hashes, thus avoiding the restarts.

In addition fixed a small issue where the bundle was not created from the certificateManager. This is the only instance in the non-test code where this is the case.

I was able to demonstrate the fix in a cluster:

apiVersion: v1
data:
  ca-bundle.crt: ""
  tigera-ca-bundle.crt: |+
    # certificate name: tigera-operator/tigera-ca-private
    -----BEGIN CERTIFICATE-----
    MIIDKTCCAhGgAwIBAgIIK+g+5SziQwowDQYJKoZIhvcNAQELBQAwITEfMB0GA1UE
    AxMWdGlnZXJhLW9wZXJhdG9yLXNpZ25lcjAgFw0yNDA4MzAxOTE5MTlaGA8yMTI0
    MDgwNjE5MTkyMFowITEfMB0GA1UEAxMWdGlnZXJhLW9wZXJhdG9yLXNpZ25lcjCC
    ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJKVPjc89JBa+EZZEtzy4emL
    qPaTpwj45CUN+bfYSoma5AYqfKOxZasCHJb8lbws+gXgYZauMNJ05FKmUibrbJkQ
    HxwC+Clio4ZKYqvEWnIxLvfekj4praf2qkQvqXpVkpdi6iBc4GOVUPKtWX5zOMXA
    lxyvTJtyyZLAHwqswMKEV9LBMKfSZs8zgz73NeyJ8cVG5LO9LZnY/ZBG3b/ek7LQ
    Wl2w+Fh/TFQtVbPnxehy17hTO2iV0qAOnC9njvpXSpgoJIAfTevSC0K3GTBl3B73
    H7YpyAOUMoMb8dRRxZgTuNSvs0WiYaz+q0g5XcjnkyPaUokSqo63FXMCvgvOgZ0C
    AwEAAaNjMGEwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
    BBYEFPyrJ/vgJQOgUz+YP3nb4i4nq9gDMB8GA1UdIwQYMBaAFPyrJ/vgJQOgUz+Y
    P3nb4i4nq9gDMA0GCSqGSIb3DQEBCwUAA4IBAQBF2+OEqnNpiWmcqG2bT3cLMbdK
    5IOj5iRJ0wFDTfdQTduPrjVzbAGU0qZ9RJCsXMIfnxCYSC0w3OSqVCCWoKrvnzZG
    vR/TAEmZxzW+TVif6SObIIjk/DRJja9xPf5XTT0RpI1MyGLEGG1yx1MgVbm9MQFn
    nVPywsc2ojJ0nksl7z0rc2P/aNd4qLoevM29Htyz5gBnOo2f6TV666wWq2YTQu+N
    74I3QHFmk4RfI6/i/iBajuRaNcHbPnXqzHkJc2X9fJ5zvfxgFIBH9Jf7+5X3TTt3
    5cHPhUVAdRMomwnLG1YZdLkWZpBP876pKIrM537u5x4dEUVMvbzDIsNMoyOL
    -----END CERTIFICATE-----


    # certificate name: tigera-operator/tigera-secure-elasticsearch-cert
    -----BEGIN CERTIFICATE-----
    MIIFkTCCBHmgAwIBAgIIVQ2lrRiucxIwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UE
    AwwhdGlnZXJhLW9wZXJhdG9yLXNpZ25lckAxNzI5NjM2Nzg4MB4XDTI0MTAyMjIy
    Mzk0N1oXDTI0MTAyMjIzMzk0OFowKDEmMCQGA1UEAxMddGlnZXJhLXNlY3VyZS1l
    cy1nYXRld2F5LWh0dHAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC4
    /n3wOTKhMEcdMBO7wKM1RsuRxVNtUD1WrVVN1lIxbr14qdmLwkHkX0sR5JsjBepy
    XK5kkgw8VPWEb0dlccO3ytSVmpgVzYoBF2q1f81MVl6gqgBSAikz7H2ArLxHcMDM
    XYjlGxWEhRGIZQA2tcRKz3fTJaci9XsM7yDdBYpKT3ylO0OfmRfUofVCyTTnZt86
    sot3E1nSuggvZw8l060i1kQwIW8ZFSFpObquQC3pYXAo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hLWtpYmFuYS5zdmMuY2x1c3Rlci5sb2Nh
    bDANBgkqhkiG9w0BAQsFAAOCAQEAXR+R/rWKYD/JGX64Hl9cAnRwTS/vJYCkVOE8
    6VlgiCuD1oKewlohQXDTFy0fe0xWoQLrb12/HB5ESbSQUjiLmIRwdy+8X2lbtxEf
    adoOVg7g9eRvs8LHBm5vijvlG+2jEKbJKxOyDG5tePjH9H6US/dWrcBF/aPrssHA
    9abUixYwPIP7dhBPHSze8PkymQCARbj2nDVu5nIvd2w2t1vex2E18q51eRRRqKDW
    suVDp1W15DHW7jc6VKV63ARPta38saqP9+Q6BUKaLTt8uoSEaz0XVh36XDd0Ao0X
    sV2Lcun+ePEfar/uM2jeyjAeItfAkkSR9ptlWjmi5M5ByNyg2A==
    -----END CERTIFICATE-----
    -----BEGIN CERTIFICATE-----
    MIIDPzCCAiegAwIBAgIIUpnm1A11Y8wwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UE
    AwwhdGlnZXJhLW9wZXJhdG9yLXNpZ25lckAxNzI5NjM2Nzg4MCAXDTI0MTAyMjIy
    Mzk0N1oYDzIxMjQwOTI4MjIzOTQ4WjAsMSowKAYDVQQDDCF0aWdlcmEtb3BlcmF0
    b3Itc2lnbmVyQDE3Mjk2MzY3ODgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
    AoIBAQCxmfhoLKJaUdGIF3ARiC+0VHGdzvugLg9Ok3MkYYW0F+CaAoEHAePeeJ2o
    ZNAPHD5VdMpjWXu3pPg40/aFapp73o/xyxnCLuHmsJdxu9lGLLtVq9pELUZSvSSj
    y6Xut78MO0YLubA3YAQ8WGJISFxQl5LRSEn1P3bO+RRS70w8mQ3ssxbxb2ZbAdNf
    9fGA+7JH/TtQsR0sZkhteJVITv8uQt91G0XWZyyJoXQJSgip8sI7uCIryA7BZMp9
    Rv4NnoMN0e5o6vH9qUnL5wxUv5kSGDS9t4oiZVg7C1edbTIWRnOu8FH15ZB0gdB2
    97JtZW1DmF67uSZpjNtvZ28pvZDvAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwICpDAP
    BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQbupydRxwYaCXEsiR9TCmjzHCb9DAf
    BgNVHSMEGDAWgBQbupydRxwYaCXEsiR9TCmjzHCb9DANBgkqhkiG9w0BAQsFAAOC
    AQEAf/xuzaYsM899FiSRutsmJjZ2WK0TzSqwblMGcRiXt5NTBJavrLlrtbXlYGHg
    bkRrkB5x//SExjknEYnnavZoIsvhohEqwgSN4NIio5bjIsJrQ6QmUV350w8k4Mg4
    FtaOuFjoLaLkUaERP+atnxGI9Br0/nWr+pAWRTHjEdtdggdwr6nHynKIScp98MPF
    PmNLUAlEp7lW+2HM4flysA6uwVp9jbRNCONMlX9x4/XNIW2SbMKXF/LzCGI4Y2zD
    v3k14reYmOaaAoImNPABX74YKE36/QI8Z38d47S6LsDWWLLB9aiYQdWbKxA00gOP
    mThWti8g5p0GlIxSctqq3asfKQ==
    -----END CERTIFICATE-----


    # certificate name: tigera-operator/tigera-secure-kibana-cert
    -----BEGIN CERTIFICATE-----
    MIIFkTCCBHmgAwIBAgIIVQ2lrRiucxIwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UE
    AwwhdGlnZXJhLW9wZXJhdG9yLXNpZ25lckAxNzI5NjM2Nzg4MB4XDTI0MTAyMjIy
    Mzk0N1oXDTI0MTAyMjIzMzk0OFowKDEmMCQGA1UEAxMddGlnZXJhLXNlY3VyZS1l
    cy1nYXRld2F5LWh0dHAwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC4
    /n3wOTKhMEcdMBO7wKM1RsuRxVNtUD1WrVVN1lIxbr14qdmLwkHkX0sR5JsjBepy
    XK5kkgw8VPWEb0dlccO3ytSVmpgVzYoBF2q1f81MVl6gqgBSAikz7H2ArLxHcMDM
    XYjlGxWEhRGIZQA2tcRKz3fTJaci9XsM7yDdBYpKT3ylO0OfmRfUofVCyTTnZt86
    sot3E1n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l
    cmEtc2VjdXJlLWtiLWh0dHAudGlnZXJhLWtpYmFuYS5zdmMuY2x1c3Rlci5sb2Nh
    bDANBgkqhkiG9w0BAQsFAAOCAQEAXR+R/rWKYD/JGX64Hl9cAnRwTS/vJYCkVOE8
    6VlgiCuD1oKewlohQXDTFy0fe0xWoQLrb12/HB5ESbSQUjiLmIRwdy+8X2lbtxEf
    adoOVg7g9eRvs8LHBm5vijvlG+2jEKbJKxOyDG5tePjH9H6US/dWrcBF/aPrssHA
    9abUixYwPIP7dhBPHSze8PkymQCARbj2nDVu5nIvd2w2t1vex2E18q51eRRRqKDW
    suVDp1W15DHW7jc6VKV63ARPta38saqP9+Q6BUKaLTt8uoSEaz0XVh36XDd0Ao0X
    sV2Lcun+ePEfar/uM2jeyjAeItfAkkSR9ptlWjmi5M5ByNyg2A==
    -----END CERTIFICATE-----
    -----BEGIN CERTIFICATE-----
    MIIDPzCCAiegAwIBAgIIUpnm1A11Y8wwDQYJKoZIhvcNAQELBQAwLDEqMCgGA1UE
    AwwhdGlnZXJhLW9wZXJhdG9yLXNpZ25lckAxNzI5NjM2Nzg4MCAXDTI0MTAyMjIy
    Mzk0N1oYDzIxMjQwOTI4MjIzOTQ4WjAsMSowKAYDVQQDDCF0aWdlcmEtb3BlcmF0
    b3Itc2lnbmVyQDE3Mjk2MzY3ODgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
    AoIBAQCxmfhoLKJaUdGIF3ARiC+0VHGdzvugLg9Ok3MkYYW0F+CaAoEHAePeeJ2o
    ZNAPHD5VdMpjWXu3pPg40/aFapp73o/xyxnCLuHmsJdxu9lGLLtVq9pELUZSvSSj
    y6Xut78MO0YLubA3YAQ8WGJISFxQl5LRSEn1P3bO+RRS70w8mQ3ssxbxb2ZbAdNf
    9fGA+7JH/TtQsR0sZkhteJVITv8uQt91G0XWZyyJoXQJSgip8sI7uCIryA7BZMp9
    Rv4NnoMN0e5o6vH9qUnL5wxUv5kSGDS9t4oiZVg7C1edbTIWRnOu8FH15ZB0gdB2
    97JtZW1DmF67uSZpjNtvZ28pvZDvAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwICpDAP
    BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQbupydRxwYaCXEsiR9TCmjzHCb9DAf
    BgNVHSMEGDAWgBQbupydRxwYaCXEsiR9TCmjzHCb9DANBgkqhkiG9w0BAQsFAAOC
    AQEAf/xuzaYsM899FiSRutsmJjZ2WK0TzSqwblMGcRiXt5NTBJavrLlrtbXlYGHg
    bkRrkB5x//SExjknEYnnavZoIsvhohEqwgSN4NIio5bjIsJrQ6QmUV350w8k4Mg4
    FtaOuFjoLaLkUaERP+atnxGI9Br0/nWr+pAWRTHjEdtdggdwr6nHynKIScp98MPF
    PmNLUAlEp7lW+2HM4flysA6uwVp9jbRNCONMlX9x4/XNIW2SbMKXF/LzCGI4Y2zD
    v3k14reYmOaaAoImNPABX74YKE36/QI8Z38d47S6LsDWWLLB9aiYQdWbKxA00gOP
    mThWti8g5p0GlIxSctqq3asfKQ==
    -----END CERTIFICATE-----


kind: ConfigMap
metadata:
  annotations:
    tigera-operator.hash.operator.tigera.io/tigera-ca-private: b2198a76a18cf738ba59431fcde98b3462c80d71
    tigera-operator.hash.operator.tigera.io/tigera-secure-elasticsearch-cert: f6a31b2eb00d127bde08fa79a55665ea2ab9672d
    tigera-operator.hash.operator.tigera.io/tigera-secure-kibana-cert: f6a31b2eb00d127bde08fa79a55665ea2ab9672d
  creationTimestamp: "2024-08-30T19:19:21Z"
  name: tigera-ca-bundle
  namespace: tigera-elasticsearch
  ownerReferences:
  - apiVersion: operator.tigera.io/v1
    blockOwnerDeletion: true
    controller: true
    kind: LogStorage
    name: tigera-secure
    uid: ec18cc30-fb54-4172-bf6c-b0ae085f4e9e
  resourceVersion: "1772951"
  uid: 3789a16f-1be2-4910-9d6e-f022e182ed5d

The following annotations were on the linseed deploy:

  template:
    metadata:
      annotations:
        hash.operator.tigera.io/tigera-ee-linseed-elasticsearch-user-secret: be91936a3c0f1c2bfdcc23fa33c0ceed6d7c16e9
        tigera-operator.hash.operator.tigera.io/tigera-ca-private: b2198a76a18cf738ba59431fcde98b3462c80d71
        tigera-operator.hash.operator.tigera.io/tigera-secure-elasticsearch-cert: f6a31b2eb00d127bde08fa79a55665ea2ab9672d
        tigera-operator.hash.operator.tigera.io/tigera-secure-kibana-cert: f6a31b2eb00d127bde08fa79a55665ea2ab9672d
        tigera-operator.hash.operator.tigera.io/tigera-secure-linseed-cert: abe0f86594964c00bb1fa7bad48f00abd22e3bfa


…ject. That ensures that the rootCA is also in the bundle.
… them. There can be a case that a user uses the same certs for two different components. We want to avoid that components get re-rendered due to having different hashes per reconciliation loop.
@rene-dekker rene-dekker force-pushed the ensure-external-certs-have-a-hash branch from 5aab7db to db2bdf7 Compare October 18, 2024 21:38
@@ -360,7 +360,7 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
r.status.SetDegraded(operatorv1.ResourceReadError, "Failed to get certificate", err, reqLogger)
return reconcile.Result{}, err
} else if prometheusCertificate != nil {
trustedBundle = certificatemanagement.CreateTrustedBundle(prometheusCertificate)
trustedBundle = certificateManager.CreateTrustedBundle(prometheusCertificate)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed for consistency, to ensure that every bundle will contain the ca as well.

@@ -329,7 +329,7 @@ func (cm *certificateManager) GetOrCreateKeyPair(cli client.Client, secretName,
cm.log.V(3).Info("secret %s has invalid DNS names, the expected names are: %v", secretName, dnsNames)
return keyPair, nil
}
} else if keyPair == nil {
} else {
Copy link
Member Author

@rene-dekker rene-dekker Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition if keyPair == nil is always true here, so I removed it.

@@ -252,7 +253,7 @@ func getSystemCertificates() ([]byte, error) {
if err == nil {
return data, nil
}
if err != nil && !os.IsNotExist(err) {
if !os.IsNotExist(err) {
Copy link
Member Author

@rene-dekker rene-dekker Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition err != nil is always true here, so I removed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not checking if err != nil before err == nil ? It is easier to read that this. If we have an error and it is not because the file is missing we return the error.

Copy link
Member Author

@rene-dekker rene-dekker Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, but doubtful how much of an improvement it really is.

@rene-dekker rene-dekker force-pushed the ensure-external-certs-have-a-hash branch from db2bdf7 to 3270939 Compare October 21, 2024 22:04
for _, cert := range t.certificates {
certs = append(certs, cert)
}
var certs []CertificateInterface
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because it failed static checks.

}
var certs []CertificateInterface
certs = append(certs, t.certificates...)

sort.Slice(certs, func(i, j int) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sorting still needed ? If so, why can't we move this sorting after adding all certificates so that it is available for everybody ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think that there should not be a need for it, as the order in which things are added to the bundle (which is now backed by a slice, rather than a map) is deterministic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to keep the sorting regardless. (See last commit message).

@@ -252,7 +253,7 @@ func getSystemCertificates() ([]byte, error) {
if err == nil {
return data, nil
}
if err != nil && !os.IsNotExist(err) {
if !os.IsNotExist(err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not checking if err != nil before err == nil ? It is easier to read that this. If we have an error and it is not because the file is missing we return the error.

@@ -249,12 +238,13 @@ var certFiles = []string{
func getSystemCertificates() ([]byte, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed redundancy which failed the static-checks.

if !os.IsNotExist(err) {
return nil, fmt.Errorf(fmt.Sprintf("error occurred when loading system root certificate with name %s", filename), err)
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: No need for else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is needed, if we don't have the else then we'd do the return when os.IsNotExist(err) is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right.

Although we may strictly not need the sorting, we conclude that sorting
may still be desirable. It has the potential to reduce the number of
changes and if any variability in insertion error could exist, sorting
would prevent a potential bug. No need to change this.
Copy link
Member

@tmjd tmjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rene-dekker rene-dekker merged commit 3c6f506 into tigera:master Oct 24, 2024
5 checks passed
@rene-dekker rene-dekker deleted the ensure-external-certs-have-a-hash branch October 24, 2024 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants