Граф коммитов

16 Коммитов

Автор SHA1 Сообщение Дата
Brian Ramos 6bee2fe415
[vtgate] Add flag to pool connection read buffers (#11167)
* Add mysql_server_pool_conn_read_buffers flag and thread through to listener and connection

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* review feedback: code style

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* fix endtoend test

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* run benchmarks with read buffer pooling, too

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* update flag name to match new conventions

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* update 15.0.0 summary with reference to new flag

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

* an attempt at cleaning up branch for rebasing

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>

Signed-off-by: Brian Ramos <brirams@users.noreply.github.com>
2022-09-26 15:25:08 +05:30
Andrew Mason e252d31d87
[go/mysql/*] Move all authserver–related flags off of global flagset (#10752)
* [go/mysql] Move all authserver-related flags off of global flagset

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* fix flag default value relied on by tests

Signed-off-by: Andrew Mason <andrew@planetscale.com>

* fix vtgate help test data

Signed-off-by: Andrew Mason <andrew@planetscale.com>
2022-07-25 15:58:38 -07:00
Eng Zer Jun 68733e9175
test: use `T.TempDir` to create temporary test directory (#10433)
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-06-06 06:47:15 +02:00
Dirkjan Bussink 8e436cfbc8
Replace OpenSSL usage for test certificates with Go crypto
This replaces the shelling out to OpenSSL with native Go crypto to
generate CAs, intermediates & leaf certificates.

There's some improvements over the original behavior for correctness and
performance reasons.

- First, this now uses ECDSA certificates with are a lot faster and
  generating a private key for them is much faster as well.
- There were no real leaf certificates. Each certificate was also marked
  as a CA which isn't correct usage of certificates. The changes here
  ensure that a signed cert is now a proper leaf certificate. It also
  adds an explicit separate method to generate an intermediate CA.
- Lifetime of the certificates generated is significantly reduces.
  Before it was almost 10 years, now it is one day. These temporary test
  certificates should not be used for anything long term, so a day is long
  enough for testing and using them in CI setups.
- It was setting 127.0.0.1 as a DNS SAN which doesn't work. This now
  adds 127.0.0.1 (and also ::1) as a proper IP SAN.
- The original OpenSSL certificates didn't setup bits like
  x509.KeyUsageCRLSign even though basic usage was marked as critical.
  This was technically in violation of the spec but a bunch of tools
  accept it (although not Go's CRL generation logic).

The API otherwise is unchanged for the tlstest package so any users
shouldn't see any significant change, just a package that's a lot
faster.

Unscientific benchmark for the test runtime shows a huge improvement:

Before

```
go test ./go/vt/tlstest -count=1
ok  	vitess.io/vitess/go/vt/tlstest	8.024s
```

After

```
go test ./go/vt/tlstest -count=1
ok  	vitess.io/vitess/go/vt/tlstest	0.156s
```

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
2022-03-29 14:27:29 +02:00
Hormoz Kheradmand 8e06dc7f59 Add support for certification revocation list files
Signed-off-by: Hormoz Kheradmand <hormoz.kheradmand@shopify.com>
2021-10-13 17:17:07 +00:00
Eng Zer Jun ecf27f44c4
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-05 08:05:23 +08:00
Dirkjan Bussink a4f7e82481
Add additional options for configuring SSL modes as a client
In the case of for example vttablets connecting to an external MySQL,
the current TLS / SSL options don't provide the sometimes needed
flexibility.

The only way to provide any option(s) is through the `db_flags` and
setting that to the magic value if 2048 (the `CapabilityClientSSL` bit).
In this mode, it immediately moves to the strictest mode possible.

These changes make options available for Vitess users to more granularly
configure the SSL settings. It mimics the MySQL client with an SSL mode
flag that can be set to various values matching MySQL.

This flags replaces the magic constant for db_flags and allows more fine
grained control.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
2021-08-04 12:16:22 +02:00
Dirkjan Bussink d158fb7b26
Refactor authentication server plugin mechanism
This change implements a large refactor of the plugin authentication
mechanism. This refactor needed for a number of reasons:

- The current AuthServer interface is not well designed. Many of the
  AuthServer implementations implement at least one if not multiple
  methods as a panic() as they are unused or they implement something
  never really called (like the salt generation). This indicates that
  the current interface doesn't abstract things well.
- Adding `caching_sha2_password` as a server side mechanism would make
  this interface problem worse. It would add even more methods that
  would have emply implementations / panic().
- It is impossible right now for a plugin to support multiple
  authentication mechanisms. The caching_sha2_password plugin allows for
  caching of passwords and could be used to improve for example the LDAP
  plugin. But we can't then still keep the `mysql_clear_password` as a
  fallback for such an improvement in the LDAP plugin.

Based on these issues, I'm proposing this refactor. It allows for a
number of things that also make auth server implementations easier.

- An auth server can implement multiple auth methods. This allows for
  the above mentioned optimization for the LDAP plugin and many other
  improvements. Note that these improvements are not implemented here, but
  it opens up the opportunity.
- There are helpers for all the already supported authentication
  mechanisms plus basic support for caching_sha2_password. The last only
  supports TLS connections or Unix sockets right now, since the full
  authentication protocol is much complicated. The value of the latter
  is also debatable in the context of Vitess. It depends on a TLS
  certificate and private key also for the plain text full auth cycle
  and in that case, TLS would already be available as well anyway. For
  clients that want caching_sha2_password, switching those to enable TLS
  seems like a much simpler solution.
- With the helpers, specific interfaces are provided that plugins can
  implement. Those interfaces provide a simpler way than the complex
  Negotiate from before which might need to read packets etc. For these
  helpers, all reading / writing of the protocol is already dealt with and
  not something auth server plugin writers need to be concerned with.

Given the above advantages, I think the current setup is a better
design and better fits what we'd want to use for authentication plugins.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
2021-07-21 15:25:54 +02:00
Dirkjan Bussink 6c14e837d0
Allow for configuration of the minimal TLS version
TLS 1.0 & TLS 1.1 are deprecated and shouldn't be used anymore. There
are however many older MySQL versions out there where the latest 5.6,
5.7 or 8.0 patch release isn't used which means they don't have a build
against OpenSSL with latest TLS support.

This means we can't easily change the minimum version to always be TLS
1.2, but the best possible option is to create flag instead.

The changes here add support for that flag. The default still is TLS
1.2 as the minimum version, but people who run against an older MySQL
can use a new flag to override this and still allow TLS 1.0 or TLS 1.1
if desired.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
2021-07-13 11:39:10 +02:00
Evgenii Seliavka 3df553c7f3 add combine TLS certs feature
Signed-off-by: Evgenii Seliavka <eseliavka@twitter.com>
2021-03-09 19:00:45 -08:00
huiqing 6496d15094 SIGHUP for tls config update
Signed-off-by: huiqing <hzhou@pinterest.com>
2020-05-22 11:01:25 -07:00
Sugu Sougoumarane 9daae6d8c0 tests: fix unit_race
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
2019-12-22 21:55:11 -08:00
deepthi ca800b388f fix unit tests
Signed-off-by: deepthi <deepthi@planetscale.com>
2019-12-19 12:25:06 -08:00
tanjunchen 63c969ca7d add License in /go files
Signed-off-by: tanjunchen <2799194073@qq.com>
2019-10-12 00:31:28 +08:00
Dan Kozlowski 8200553641 Merge branch 'master' of github.com:vitessio/vitess into dk-backup-only
Signed-off-by: Dan Kozlowski <koz@planetscale.com>
2019-06-19 23:08:32 -07:00
tpetr 2d19dccae1 PR feedback + add tests + light refactoring
Signed-off-by: tpetr <tpetr@hubspot.com>
2019-04-02 11:03:32 -04:00