Skip to content

Add check for self-signed certs #10

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions pre-check/v1.1.x/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,34 @@ check_free_space()
record_fail
}

check_certificate()
{
echo ">>> Check certificates..."

vip=$(kubectl -n kube-system get services ingress-expose -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
if [ -z "$vip" ]; then
echo "VIP not available."
record_fail
else
echo "VIP address: $vip"
fi

cert=$(kubectl get settings.harvesterhci.io ssl-certificates -o jsonpath='{.value}' | jq -r '.publicCertificate')
if [ -z "$cert" ]; then
echo "ssl-certificates is not set."
else
echo "Checking if the user-provided certificate contains any Subject Alternative Names (SANs)..."
SAN=$(echo "$cert" | openssl x509 -inform PEM -noout -ext subjectAltName | grep -oP '(?<=DNS:|IP Address:)[^,]+' || true)
if echo "$SAN" | grep -q "$vip"; then
echo "The certificate contains the VIP address $vip"
else
echo "The SAN extension of the certificate does not contain the VIP address $vip"
echo "For more information, please visit: https://github.com/harvester/harvester/issues/4519"
record_fail
Copy link
Member

Choose a reason for hiding this comment

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

question: do not allow upgrade in such case? how can user fix it?

Choose a reason for hiding this comment

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

This script only helps to check for upgrades and does not prevent any upgrade process; however, it is not recommended to proceed with the upgrade operation if it contains an error message. And I think It would be more useful if we could link to a suggested workaround once it was available.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good, let's wait for the workaround and update here again

fi
fi
}

check_bundles
check_harvester_bundle
check_nodes
Expand All @@ -314,6 +342,7 @@ check_volumes
check_attached_volumes
check_error_pods
check_free_space
check_certificate

if [ $check_failed -gt 0 ]; then
echo ""
Expand Down