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

Fix OCP HSTS errors #282

Open
jacobdotcosta opened this issue Mar 29, 2023 · 9 comments
Open

Fix OCP HSTS errors #282

jacobdotcosta opened this issue Mar 29, 2023 · 9 comments
Assignees

Comments

@jacobdotcosta
Copy link
Member

jacobdotcosta commented Mar 29, 2023

Issue

When we access the ocp console, then we got such a message from google chrome

You cannot visit oauth-openshift.apps.ocp.snowdrop.dev right now because the website uses HSTS. Network errors and attacks are usually temporary, so this page will probably work later.

HSTS: https://developer.mozilla.org/en-US/docs/Glossary/HSTS

Temporary workaround is to type thisisunsafe within the google chrome window - https://stackoverflow.com/questions/33268264/chromethe-website-uses-hsts-network-errors-this-page-will-probably-work-late

@jacobdotcosta jacobdotcosta self-assigned this Mar 29, 2023
@jacobdotcosta jacobdotcosta transferred this issue from snowdrop/team Apr 10, 2023
@cmoulliard
Copy link
Member

Dont forget to add the link to the issue/PR to track that from your tasks ;-)

@cmoulliard
Copy link
Member

Can you add the link to the ticket created please ? @jacobdotcosta

@jacobdotcosta
Copy link
Member Author

jacobdotcosta commented May 29, 2023

@cmoulliard
Copy link
Member

I think that I know how to fix it.

We dont have issues when we access https://console-openshift-console.snowdrop-eu-de-1-bx2-4x16-0c576f1a70d464f092d8591997631748-0000.eu-de.containers.appdomain.cloud/ as their HTTPS certificate has been signed for the domain *.cloud by Let's encrypt - https://letsencrypt.org/certificates/#intermediate-certificates

-----BEGIN CERTIFICATE-----
MIIGRzCCBS+gAwIBAgISBIq2+AqEbznEOBnuHHqEpCBdMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yMzA0MTMwNDEzNDdaFw0yMzA3MTIwNDEzNDZaMEUxQzBBBgNVBAM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kb21haW4uY2xvdWSCOnNub3dkcm9wLWV1LWRlLTEtYngyLTR4MTYu
ZXUtZGUuY29udGFpbmVycy5hcHBkb21haW4uY2xvdWQwTAYDVR0gBEUwQzAIBgZn
gQwBAgEwNwYLKwYBBAGC3xMBAQEwKDAmBggrBgEFBQcCARYaaHR0cDovL2Nwcy5s
ZXRzZW5jcnlwdC5vcmcwggEFBgorBgEEAdZ5AgQCBIH2BIHzAPEAdwC3Pvsk35xN
unXyOcW6WPRsXfxCz3qfNcSeHQmBJe20mQAAAYd5CLg8AAAEAwBIMEYCIQDknrov
P4dsaO9cowbaK+W8qnFXlw2CXWmDqCga4jjvJgIhALDONveWD9P133Lcozni7WIT
Pt22QP4tj8zM7DQw0gzdAHYAejKMVNi3LbYg6jjgUh7phBZwMhOFTTvSK8E6V6NS
61IAAAGHeQi4TAAABAMARzBFAiEAxpLBPpag94JhLAf52vnYg0ShaQcBrQ5D9dkE
DcDHSCUCIGzt0Y+JaJN+0lvhZtoYLok8jTMJeFWI4tHxTkkGsgoQMA0GCSqGSIb3
DQEBCwUAA4IBAQCCQQ2GI1EkukC1GLUKpRcB2d7a0QrW1eu0qHOmyaH44G1Fii+X
DEUXVe93m9nROyG0ZdFhvxIHVuIylH31Q3UEOE0DtMHT3pYCzg+vs93jIFPXXL1C
1f52mt0TKsGnnPxUzHI0CqWZ4YKIAP+QURLVURQoe5YlvqMC3Mn0mW7tZKdrlnil
GnrXsveCz6oKbAtvoP8bMGWWsltrMjUZHZOB6lOvcQJoocxDZfCdHBoMjL+SugZ5
4DCqWHueRJc7o4Vdxcq3gNuCJ8YrYP7V3hZ4ustjBSPQBdlcBezmSuJ/DuQwCok2
TAMzaIP3LnDk+uYowmfELaIH3q+t7lj7HION
-----END CERTIFICATE-----

instead the certificate generated by the ocp ingress operator for us

    -----BEGIN CERTIFICATE-----
    MIIDZTCCAk2gAwIBAgIIM5L+uC/xI+YwDQYJKoZIhvcNAQELBQAwJjEkMCIGA1UE
    AwwbaW5ncm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yngnGcnQfuKXI/rkxYxHPh4e6/kI+hzwZ+YzeP9X/pzZq8ZvP
    B9J1OVll7vas
    -----END CERTIFICATE-----

So, if we ask to Let's encrypt and Godaddy to sign a Certificate request for *.apps.ocp.snowdrop.dev, that should work.

The next challenge will be to pass such a certificate within the Openstack ocp install config file. Maybe using: https://docs.openshift.com/container-platform/4.13/installing/installing_openstack/installing-openstack-installer-custom.html#installation-osp-describing-cloud-parameters_installing-openstack-installer-custom

WDYT ? @jacobdotcosta

@cmoulliard
Copy link
Member

cmoulliard commented May 30, 2023

I tested manually this procedure after updating the certificate and issuer role of k8s-infra, collected the updated secret and patched as described here: https://docs.openshift.com/container-platform/4.13/security/certificates/replacing-default-ingress-certificate.html#replacing-default-ingress_replacing-default-ingress

Now, the access to https://console-openshift-console.apps.ocp.snowdrop.dev/dashboards do not generate a HTST error ;-)

oc login is reporting nevertheless an error

oc login --token=sha256~xxxx --server=https://api.ocp.snowdrop.dev:6443
error: x509: “kube-apiserver-lb-signer” certificate is not trusted

FYI: @jacobdotcosta

@cmoulliard
Copy link
Member

A part of the problem could be automated if we pass to the openshift installer config file the parameter additionalTrustBundle
See how that works here: https://github.com/openshift/installer/blob/master/docs/user/customization.md#proxy which corresponds to what it is described here: https://docs.openshift.com/container-platform/4.13/security/certificates/replacing-default-ingress-certificate.html#replacing-default-ingress_replacing-default-ingress (create a custom CA secret and patch proxy/cluster)

NOTE: We need of course to populate first and separately the CA crt and keys before to create a cluster !

@jacobdotcosta

@cmoulliard
Copy link
Member

I still have an issue using such certificate/issuer

---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: letsencrypt-prod-qshift-snowdrop-dev
  labels:
    app: qshift-ca-cert
  namespace: snowdrop-site
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email:
    privateKeySecretRef:
      name: letsencrypt-prod-snowdrop-dev
    solvers:
      - dns01:
          webhook:
            config:
              apiKeySecretRef:
                name: godaddy-api-key
                key: token
              production: true
              ttl: 600
            groupName: acme.mycompany.com
            solverName: godaddy
        selector:
          dnsNames:
            - 'api.qshift.snowdrop.dev'
            - 'oauth-openshift.apps.qshift.snowdrop.dev'
            - 'console-openshift-console.apps.qshift.snowdrop.dev'
            - 'grafana-openshift-monitoring.apps.qshift.snowdrop.dev'
            - 'prometheus-k8s-openshift-monitoring.apps.qshift.snowdrop.dev'
            - 'integrated-oauth-server-openshift-authentication.apps.qshift.snowdrop.dev'
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: qshift-snowdrop-dev
  labels:
    app: qshift-ca-cert
  namespace: snowdrop-site
spec:
  renewBefore: 2136h
  duration: 2190h
  privateKey:
    size: 2048
    algorithm: RSA
  issuerRef:
    kind: Issuer
    name: letsencrypt-prod-qshift-snowdrop-dev
  secretName: qshift-snowdrop-dev-tls
  dnsNames:
    - 'api.qshift.snowdrop.dev'
    - 'oauth-openshift.apps.qshift.snowdrop.dev'
    - 'console-openshift-console.apps.qshift.snowdrop.dev'
    - 'grafana-openshift-monitoring.apps.qshift.snowdrop.dev'
    - 'prometheus-k8s-openshift-monitoring.apps.qshift.snowdrop.dev'
    - 'integrated-oauth-server-openshift-authentication.apps.qshift.snowdrop.dev'
Screenshot 2023-11-21 at 19 13 26

@cmoulliard
Copy link
Member

Problem fixed after issuing the following certificate

apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
  name: letsencrypt-prod-qshift-snowdrop-dev
  labels:
    app: qshift-ca-cert
  namespace: snowdrop-site
spec:
  acme:
    server: https://acme-v02.api.letsencrypt.org/directory
    email:
    privateKeySecretRef:
      name: letsencrypt-prod-snowdrop-dev
    solvers:
      - dns01:
          webhook:
            config:
              apiKeySecretRef:
                name: godaddy-api-key
                key: token
              production: true
              ttl: 600
            groupName: acme.mycompany.com
            solverName: godaddy
        selector:
          dnsNames:
            - '*.apps.qshift.snowdrop.dev'
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: qshift-snowdrop-dev
  labels:
    app: qshift-ca-cert
  namespace: snowdrop-site
spec:
  renewBefore: 2136h
  duration: 2190h
  privateKey:
    size: 2048
    algorithm: RSA
  issuerRef:
    kind: Issuer
    name: letsencrypt-prod-qshift-snowdrop-dev
  secretName: qshift-snowdrop-dev-tls
  dnsNames:
    - '*.apps.qshift.snowdrop.dev'

@cmoulliard
Copy link
Member

Question from Antonio: To install the new cert manager on the OCP cluster we would still need the one on the snowdrop k8s server right?

Charles's response:
No.

It is not needed to centralize everything on a cluster EXCEPT when rotation will take place and when secrets (= ca, tls) are still used.

  • So if we don't centralize, that means that we need to find a way to "copy/scp" the secret or rotated secret to the target cluster
  • If we install a cert manager / cluster, then it can also manage the rotation and save locally the secret. If the cluster is then removed, no need anymore to rotate the cert as needed by letsencrypt after 3months

@jacobdotcosta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants