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

Add go 1.19 #224

Merged
merged 7 commits into from
Mar 7, 2023
Merged

Add go 1.19 #224

merged 7 commits into from
Mar 7, 2023

Conversation

MathieuBordere
Copy link
Contributor

@MathieuBordere MathieuBordere commented Mar 6, 2023

This PR introduces:

  • Update SimpleTLSConfig: The current config doesn't seem to be compatible with go 1.19.6 making connections fail with write handshake: local error: tls: bad record MAC see e.g. here, don't know root cause yet and it's probably not a good idea to wait for a new go release if it would indeed be a bug in go (which it is probably not).
    The config in this PR fixes the issue. Anyone has an opinion on the proposed config in this PR?
  • Run CI on Ubuntu 22.04.
  • Disable running CI on Ubuntu 18.04
  • Add go versions until 1.19 to CI.
  • Fix some issues when upgrading to go 1.19.x
    • removing deadcode, overalls
    • used buffered channel for os.Signal
    • make sure there's only 1 Output comment at end of function

edit: Just removing the curve preferences from the config seems to also fix the issue, this is probably a safer bet than also forcing TLS 1.3

@MathieuBordere MathieuBordere marked this pull request as draft March 6, 2023 09:16
Mathieu Borderé added 6 commits March 6, 2023 12:56
- add go 1.19.{5,6}
- remove Ubuntu 18.04 and add 22.04
…eters

Signed-off-by: Mathieu Borderé <mathieu.bordere@canonical.com>
Signed-off-by: Mathieu Borderé <mathieu.bordere@canonical.com>
Signed-off-by: Mathieu Borderé <mathieu.bordere@canonical.com>
seems incompatible with go 1.19

Signed-off-by: Mathieu Borderé <mathieu.bordere@canonical.com>
Signed-off-by: Mathieu Borderé <mathieu.bordere@canonical.com>
@MathieuBordere
Copy link
Contributor Author

@tomponline @cole-miller Mostly just asking feedback on the updated SimpleTLSConfig, will do more research myself on possible consequences, but your input is very welcome.

@MathieuBordere
Copy link
Contributor Author

MathieuBordere commented Mar 6, 2023

My worry is a bit that current users could use certificates that are incompatible with TLS 1.3

I could do a sanity check on the provided cert and certpool, like setup a server and client with the provided config and see if I can setup a connection. If not, revert to TLS 1.2 or err out.

@tomponline
Copy link
Member

CC @simondeziel may have a comment on this .

@@ -44,7 +44,7 @@ const (
)

func signalChannel() chan os.Signal {
ch := make(chan os.Signal)
ch := make(chan os.Signal, 32)
Copy link
Member

Choose a reason for hiding this comment

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

Why 32 out of interest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can probably be a lot smaller, just took a large enough value. I don't think the overhead is significant as it's only in used in the demo and benchmark commands.

Copy link
Member

Choose a reason for hiding this comment

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

Its fine, just I always wonder about "magic numbers" :)

@tomponline
Copy link
Member

My worry is a bit that current users could use certificates that are incompatible with TLS 1.3

I could do a sanity check on the provided cert and certpool, like setup a server and client with the provided config and see if I can setup a connection. If not, revert to TLS 1.2 or err out.

I think I would be leaning towards removing as many of the explicitly set options as possible and relying on the defaults from Go as they change from version to version (thinking MinVersion, MaxVersion, CurvePreferences, PreferServerCipherSuites (deprecated), CipherSuites).

And then make that clear in the comment, and if a user needs specific config then they can create a custom config.

Let go manage sane defaults, except MinVersion, a server can still use
TLS 1.0 which seems a bit too old imo.

- value from `curvePreferences` breaks go 1.19.6 so removed it.
- `PreferServerCipherSuites` is deprecated.
- Let go manage `CipherSuites` as it will take a safe default list.
Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

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

I quite like the simplification for the TLS server and client.

LXD 5.0+ requires TLS 1.3 unless LXD_INSECURE_TLS is set and that applies to both the server and the client.

@MathieuBordere MathieuBordere marked this pull request as ready for review March 6, 2023 15:36
@MathieuBordere
Copy link
Contributor Author

@freeekanayaka maybe you have an opinion on the TLS configs?

@cole-miller
Copy link
Contributor

I am very far from being a TLS guru, but I agree with @tomponline that removing explicitly set options (especially very technical stuff like preferred elliptic curves) from the config is a good idea, since we can trust the Go folks to pick solid defaults.

@@ -28,7 +28,6 @@ func Example() {
}

fmt.Printf("0x%x %s\n", node.ID(), node.Address())
// Output: 0x2dc171858c3155be 127.0.0.1:9001
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this change needed? Has format of testable examples changed in Go 1.19? I would be very surprised.

Copy link
Contributor Author

@MathieuBordere MathieuBordere Mar 6, 2023

Choose a reason for hiding this comment

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

go 1.19 only allows a single Output comment block and there is already one at the end of the function see e.g. this test run.

# github.com/canonical/go-dqlite/app_test
Error: app/example_test.go:31:2: there can only be one output comment block per example
Error: app/example_test.go:95:2: output comment block must be the last comment block

@freeekanayaka
Copy link
Contributor

Looks good to me. Those settings were the "recommended" ones in terms of tightening TLS parameters, but it seems reasonable to just use Go's defaults, which might be a bit more permissive, but clearly good enough.

@MathieuBordere MathieuBordere merged commit 7d04094 into canonical:master Mar 7, 2023
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.

None yet

5 participants