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

feat: allow insecure https #68

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

Conversation

julienrbrt
Copy link

@julienrbrt julienrbrt commented Jun 2, 2024

When changing machine and forgetting to back up ~/.config/gokrazy, you can end up in a locked state if you have SSL enabled.

Basically, running gok update --insecure will give, as the instance has TLS enabled:

2024/06/03 00:17:18 updating root file system: unexpected HTTP status code: got 400 Bad Request, want 200 (body "expected a PUT request\n")

On the other hand, not using the insecure flag will fail at certificate verification:

2024/06/03 00:07:36 checking target partuuid support: Get "https://gokrazy:***@rpi-gokrazy/update/features": tls: failed to verify certificate: x509: certificate signed by unknown authority (possibly because of "x509: invalid signature: parent certificate cannot sign this kind of certificate" while trying to verify candidate authority certificate "gokrazy")

If TLS is enabled, GetRemoteScheme gets already the correct scheme, so we should still set it, regardless of the insecure flag, so we can query the correct endpoint (without cert verification).

Copy link
Contributor

@stapelberg stapelberg left a comment

Choose a reason for hiding this comment

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

Thanks for your PR!

@@ -1467,7 +1467,7 @@ func (pack *Pack) logic(programName string) error {
done := measure.Interactively("probing https")
remoteScheme, err := httpclient.GetRemoteScheme(updateBaseUrl)
done("")
if remoteScheme == "https" && !tlsflag.Insecure() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t think we can make this change. The -insecure flag is supposed to prevent HTTPS probing to allow folks to first enable TLS.

Based on the error message you provided, it seems to me like the updater.NewTarget() call in line 1494 is what fails, so I’m not sure how your suggested change helps with that…?

Copy link
Author

@julienrbrt julienrbrt Jun 5, 2024

Choose a reason for hiding this comment

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

GetRemoteScheme does not return https if TLS isn't enabled.

And this insecure check prevents to keep setting the address scheme to https when the server actually supports https. So it fallbacks to http (when passing insecure), which doesn't work with TLS enabled.

The original https error is unrelated to this fix.

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

Successfully merging this pull request may close these issues.

2 participants