gokrazy / tools

this repository contains the gok CLI tool of gokrazy

Home Page:https://gokrazy.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TLS applied when -insecure set

andig opened this issue · comments

commented

Using the updater to generate certs with a new hostname works fine and uses http:

❯ go run github.com/gokrazy/tools/cmd/gokr-packer -update yes -hostname foo -tls=self-signed -insecure github.com/gokrazy/breakglass github.com/gokrazy/hello
2021/01/04 12:33:12 packer.go:353: building [github.com/gokrazy/breakglass github.com/gokrazy/hello]
Generating new self-signed certificate...
https://gokrazy:FIat2WTD8i3tJikkvIJI@foo/
2021/01/04 12:33:19 httpclient.go:46: Using certificate /Users/andig/Library/Application Support/gokrazy/hosts/foo/cert.pem
2021/01/04 12:33:19 packer.go:827: probing url for https: Get "http://foo": dial tcp: lookup foo: no such host
exit status 1

Doing the same with a previously generated host that contains certificates in the config folder still tries to use TLS although -insecure is given:

❯ go run github.com/gokrazy/tools/cmd/gokr-packer -update yes -hostname evcc -tls=self-signed -insecure github.com/gokrazy/breakglass github.com/gokrazy/hello
2021/01/04 12:33:36 packer.go:353: building [github.com/gokrazy/breakglass github.com/gokrazy/hello]
https://gokrazy:FIat2WTD8i3tJikkvIJI@evcc/
2021/01/04 12:33:41 httpclient.go:46: Using certificate /Users/andig/Library/Application Support/gokrazy/hosts/evcc/cert.pem
2021/01/04 12:33:41 packer.go:827: checking target partuuid support: Get "https://gokrazy:***@evcc/update/features": dial tcp 192.168.0.63:443: connect: connection refused
exit status 1

Seems the problem is https://github.com/gokrazy/tools/blob/master/cmd/gokr-packer/packer.go#L451 where https is prematurely applied.

Will send PR.