mirror of
https://github.com/rqlite/rqlite.git
synced 2026-01-25 04:16:26 +00:00
Remove unused TLS mux parameters
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
- [PR #2206](https://github.com/rqlite/rqlite/pull/2206): Add convenience WriteOne() to Queue.
|
||||
- [PR #2204](https://github.com/rqlite/rqlite/pull/2204): Add byte-marshalling for CDC Events.
|
||||
- [PR #2205](https://github.com/rqlite/rqlite/pull/2205): Improve CDC Protobuf naming.
|
||||
- [PR #2208](https://github.com/rqlite/rqlite/pull/2208): Remove unused parameters from TLS mux functions.
|
||||
|
||||
## v8.43.2 (August 6th 2025)
|
||||
### Implementation changes and bug fixes
|
||||
|
||||
@@ -105,7 +105,7 @@ func mustNewTLSMux(t *testing.T) (net.Listener, *tcp.Mux) {
|
||||
cert := x509.CertExampleDotComFile(t.TempDir())
|
||||
key := x509.KeyExampleDotComFile(t.TempDir())
|
||||
|
||||
mux, err := tcp.NewTLSMux(ln, nil, cert, key, "", true, false)
|
||||
mux, err := tcp.NewTLSMux(ln, nil, cert, key)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create TLS mux: %s", err))
|
||||
}
|
||||
|
||||
@@ -422,8 +422,11 @@ func startNodeMux(cfg *Config, ln net.Listener) (*tcp.Mux, error) {
|
||||
b.WriteString(", mutual TLS disabled")
|
||||
}
|
||||
log.Println(b.String())
|
||||
mux, err = tcp.NewTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert,
|
||||
cfg.NoNodeVerify, cfg.NodeVerifyClient)
|
||||
if cfg.NodeVerifyClient {
|
||||
mux, err = tcp.NewMutualTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert)
|
||||
} else {
|
||||
mux, err = tcp.NewTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key)
|
||||
}
|
||||
} else {
|
||||
mux, err = tcp.NewMux(ln, adv)
|
||||
}
|
||||
|
||||
@@ -902,7 +902,7 @@ func mustNewOpenTLSMux(certFile, keyPath, addr string) *tcp.Mux {
|
||||
}
|
||||
|
||||
var mux *tcp.Mux
|
||||
mux, err = tcp.NewTLSMux(ln, nil, certFile, keyPath, "", true, false)
|
||||
mux, err = tcp.NewTLSMux(ln, nil, certFile, keyPath)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to create node-to-node mux: %s", err.Error()))
|
||||
}
|
||||
|
||||
12
tcp/mux.go
12
tcp/mux.go
@@ -106,15 +106,15 @@ func NewMux(ln net.Listener, adv net.Addr) (*Mux, error) {
|
||||
}
|
||||
|
||||
// NewTLSMux returns a new instance of Mux for ln, and encrypts all traffic
|
||||
// using TLS. If adv is nil, then the addr of ln is used. If insecure is true,
|
||||
// then the server will not verify the client's certificate. If mutual is true,
|
||||
// then the server will require the client to present a trusted certificate.
|
||||
func NewTLSMux(ln net.Listener, adv net.Addr, cert, key, caCert string, insecure, mutual bool) (*Mux, error) {
|
||||
return newTLSMux(ln, adv, cert, key, caCert, false)
|
||||
// using TLS. If adv is nil, then the addr of ln is used. The server will not
|
||||
// require clients to present a valid certificate since mutual TLS is not enabled.
|
||||
func NewTLSMux(ln net.Listener, adv net.Addr, cert, key string) (*Mux, error) {
|
||||
return newTLSMux(ln, adv, cert, key, "", false)
|
||||
}
|
||||
|
||||
// NewMutualTLSMux returns a new instance of Mux for ln, and encrypts all traffic
|
||||
// using TLS. The server will also verify the client's certificate.
|
||||
// using TLS. The server will also require clients to present a valid certificate.
|
||||
// If caCert is not empty, that CA certificate will be added to the pool of CAs.
|
||||
func NewMutualTLSMux(ln net.Listener, adv net.Addr, cert, key, caCert string) (*Mux, error) {
|
||||
return newTLSMux(ln, adv, cert, key, caCert, true)
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ func TestTLSMux(t *testing.T) {
|
||||
key := x509.KeyExampleDotComFile("")
|
||||
defer os.Remove(key)
|
||||
|
||||
mux, err := NewTLSMux(tcpListener, nil, cert, key, "", true, false)
|
||||
mux, err := NewTLSMux(tcpListener, nil, cert, key)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create mux: %s", err.Error())
|
||||
}
|
||||
@@ -193,6 +193,7 @@ func TestTLSMux(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
state := conn.ConnectionState()
|
||||
if !state.HandshakeComplete {
|
||||
@@ -217,6 +218,7 @@ func TestTLSMux(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
state = conn.ConnectionState()
|
||||
if !state.HandshakeComplete {
|
||||
@@ -230,12 +232,53 @@ func TestTLSMux(t *testing.T) {
|
||||
func TestTLSMux_Fail(t *testing.T) {
|
||||
tcpListener := mustTCPListener("127.0.0.1:0")
|
||||
defer tcpListener.Close()
|
||||
_, err := NewTLSMux(tcpListener, nil, "xxxx", "yyyy", "", true, false)
|
||||
_, err := NewTLSMux(tcpListener, nil, "xxxx", "yyyy")
|
||||
if err == nil {
|
||||
t.Fatalf("created mux unexpectedly with bad resources")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMutualTLSMux(t *testing.T) {
|
||||
tcpListener := mustTCPListener("127.0.0.1:0")
|
||||
defer tcpListener.Close()
|
||||
|
||||
cert := x509.CertExampleDotComFile("")
|
||||
defer os.Remove(cert)
|
||||
key := x509.KeyExampleDotComFile("")
|
||||
defer os.Remove(key)
|
||||
caCert := x509.CertMyCAFile("")
|
||||
defer os.Remove(caCert)
|
||||
|
||||
mux, err := NewMutualTLSMux(tcpListener, nil, cert, key, caCert)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create mutual TLS mux: %s", err.Error())
|
||||
}
|
||||
defer mux.Close()
|
||||
go mux.Serve()
|
||||
|
||||
if mux.tlsConfig.ClientAuth != tls.RequireAndVerifyClientCert {
|
||||
t.Fatalf("expected RequireAndVerifyClientCert, got %v", mux.tlsConfig.ClientAuth)
|
||||
}
|
||||
|
||||
conn, err := tls.Dial("tcp", tcpListener.Addr().String(), &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// Ensure mutual TLS is being enforced.
|
||||
var b [1]byte
|
||||
_, err = conn.Read(b[:])
|
||||
if err == nil {
|
||||
t.Fatalf("expected error reading from mux enforcing mutual TLS, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "certificate required") {
|
||||
t.Fatalf("expected error to reference missing client certificate, got %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
type mockAddr struct {
|
||||
Nwk string
|
||||
Addr string
|
||||
|
||||
97
testdata/x509/resources.go
vendored
97
testdata/x509/resources.go
vendored
@@ -32,6 +32,20 @@ func KeyExample2DotComFile(dir string) string {
|
||||
return mustWriteToFile(dir, keyExample2DotCom)
|
||||
}
|
||||
|
||||
// CertMyCAFile returns the path to a temporary file, in directory dir, containing
|
||||
// a cert for MyCA. It is up to the caller to remove the file when finished. If
|
||||
// dir is the empty string then the default directory for temporary files is used.
|
||||
func CertMyCAFile(dir string) string {
|
||||
return mustWriteToFile(dir, certMyCA)
|
||||
}
|
||||
|
||||
// KeyMyCAFile returns the path to a temporary file, in directory dir, containing
|
||||
// a key for MyCA. It is up to the caller to remove the file when finished. If
|
||||
// dir is the empty string then the default directory for temporary files is used.
|
||||
func KeyMyCAFile(dir string) string {
|
||||
return mustWriteToFile(dir, keyMyCA)
|
||||
}
|
||||
|
||||
func mustWriteToFile(dir, content string) string {
|
||||
b := []byte(content)
|
||||
|
||||
@@ -194,3 +208,86 @@ xL6SNC89BNBLv/b0lF56wZLJFxNUpGXhXubKkVs2R1RXD1g8jBLxxYDDojRjWNKS
|
||||
g9XUfUSm7eCstxigUwWFO6KVeoSD/D6dfWZr9SPY9rjR1LC0ZiC/nyZ98G2NG/FR
|
||||
QgBvCKLHjbZEXIu034vg9i+R4rsTsA==
|
||||
-----END PRI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GgDP4RCQJTAfBgNVHSMEGDAWgBQuhJuI
|
||||
W4kDYOwbifxQGgDP4RCQJTAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUA
|
||||
A4ICAQBsa1DPa5JMGKkoIiW9bXOvphp4CptsLyZrS7Wr2AvbY8UI8baZM4nQFEJJ
|
||||
Im+Ki9fPoewPKAwb3yv9SLMkfqkSyfO06vgv/8G6ZeA7E1iL9HybM7DMtMn7/sZr
|
||||
BDiZreArMhkCTtgkFFa1dUkoYeliQwQUZE22IZp/ekeb7dB44mGNlego2O4exJ57
|
||||
RTRTdRI7oBhSe9Q4pum0phASY+DTLw9s44cHq9ZDner2lFHLxRUBu+JKn6IrYwNP
|
||||
HlLrRwpAIVBTaJjYTaFTEwMbMtssY206INVvGAps7nhnVSE/OcHGVj/SMJpg/2Qg
|
||||
xoEEKJWzXAYwnqLSzDwg3KJAu4UdxsN3S/5GddqvUds2VDu1R1XgYZkve/ZZDHKN
|
||||
kP6FUIyi1daHUUJKDguj3Aepws/s7XlCeqwGELPObmY3rCWKv7Y7TBSPHMafndmq
|
||||
TKKq7u873ismVdQYp6KJ4lApNFIN5dmm28nFLmxii9Q7lbwlPsq1p1W6AhDLFNdi
|
||||
6eT/17pRxZ37rEXEfOIKZf3ZBc6DuZmMs/HLiPlE8tU4kcFBR++hNEmSPeDepP3F
|
||||
ZHrVZiE433Be0VCKa8Ew3gDB9e4XVWvd2Sny02F4VsV16x4gFfqqASxHDjXSVwrQ
|
||||
f3KZus/PhFncv3YcyqZhQbIKNrLsiLg6bCoFo6TGw0r4e3AeeA==
|
||||
-----END CERTIFICATE-----`
|
||||
|
||||
const keyMyCA = `-----BEGIN PRIVATE KEY-----
|
||||
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQCZItLyzq8L36rM
|
||||
wjw1qqJ46neTDd0ehuOI5hwi0f1YRR3o5PwTGgRJQurhb6xQyH+RL6YQ5wuJJiBF
|
||||
R2Ev4lmP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niZL1v+6JgYgK60L1Uj8PmdVjPWmvyvR29zcIBezPnxUPfdxuox59kdkXewHlY
|
||||
JWSva+1sRpG7RkUO5VbdhZ7CUKg1
|
||||
-----END PRIVATE KEY-----`
|
||||
|
||||
Reference in New Issue
Block a user