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 openssl SAN check on newer versions of OpenSSL #11277

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhamzahkhan
Copy link

What type of PR is this?

/kind bug

What this PR does / why we need it:
Newer versions of OpenSSL appear to return an exit code of 1 if the checkhost doesn't match. Older versions of OpenSSL seem to return a 0 regardless of if it matched or not:

[root@lab-loadbalancer-01-lon1-uk ~]# openssl version
OpenSSL 3.1.1 30 May 2023 (Library: OpenSSL 3.1.1 30 May 2023)

[root@lab-loadbalancer-01-lon1-uk ~]# openssl x509 -noout -in apiserver.crt -checkhost lab-master-01-lon1-uk.cluster.local && echo "Matched" || echo "Did not match"
Hostname lab-master-01-lon1-uk.cluster.local does match certificate
Matched

[root@lab-loadbalancer-01-lon1-uk ~]# openssl x509 -noout -in apiserver.crt -checkhost i-should-not-match && echo "Matched" || echo "Did not match"
Hostname i-should-not-match does NOT match certificate
Matched

root@lab-master-01-lon1-uk:/etc/kubernetes/ssl# openssl version
OpenSSL 3.2.1 30 Jan 2024 (Library: OpenSSL 3.2.1 30 Jan 2024)

root@lab-master-01-lon1-uk:/etc/kubernetes/ssl# openssl x509 -noout -in apiserver.crt -checkhost lab-master-01-lon1-uk.cluster.local && echo "Matched" || echo "Did not match"
Hostname lab-master-01-lon1-uk.cluster.local does match certificate
Matched

root@lab-master-01-lon1-uk:/etc/kubernetes/ssl# openssl x509 -noout -in apiserver.crt -checkhost i-should-not-match && echo "Matched" || echo "Did not match"
Hostname i-should-not-match does NOT match certificate
Did not match

This causes ansible to exit on the SAN check:

TASK [kubernetes/control-plane : Kubeadm | Check apiserver.crt SAN hosts] ***************************************************
....
failed: [lab-master-01-lon1-uk.k8s.intahnet.co.uk] (item=lab-master-01-lon1-uk.cluster.local) => {"ansible_loop_var": "item", "changed": true, "cmd": ["openssl", "x509", "-noout", "-in", "/etc/kubernetes/ssl/apiserver.crt", "-checkhost", "lab-master-01-lon1-uk.cluster.local"], "delta": "0:00:00.022344", "end": "2024-06-07 06:19:02.072828", "item": "lab-master-01-lon1-uk.cluster.local", "msg": "non-zero return code", "rc": 1, "start": "2024-06-07 06:19:02.050484", "stderr": "", "stderr_lines": [], "stdout": "Hostname lab-master-01-lon1-uk.cluster.local does NOT match certificate", "stdout_lines": ["Hostname lab-master-01-lon1-uk.cluster.local does NOT match certificate"]}
....

NO MORE HOSTS LEFT **********************************************************************************************************

Adding ignore_errors: true should fix this

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added the release-note-none Denotes a PR that doesn't merit a release note. label Jun 7, 2024
Copy link

linux-foundation-easycla bot commented Jun 7, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: mhamzahkhan / name: M. Hamzah Khan (68f4082)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jun 7, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhamzahkhan
Once this PR has been reviewed and has the lgtm label, please assign yankay for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 7, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @mhamzahkhan. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 7, 2024
@k8s-ci-robot k8s-ci-robot requested a review from yankay June 7, 2024 10:59
@mhamzahkhan mhamzahkhan marked this pull request as draft June 7, 2024 11:00
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 7, 2024
@mhamzahkhan mhamzahkhan force-pushed the fcos40-fix-openssl-san-check branch from a6344f9 to 68f4082 Compare June 7, 2024 11:01
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jun 7, 2024
@mhamzahkhan mhamzahkhan marked this pull request as ready for review June 7, 2024 11:06
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 7, 2024
@VannTen
Copy link
Contributor

VannTen commented Jun 7, 2024 via email

@yankay
Copy link
Member

yankay commented Jun 18, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants