stderr debugging for #517 (tls: bad certificate)

refs #517

cc @asomers
This commit is contained in:
Christian Schwarz 2021-09-20 07:43:22 +02:00
parent b54e477602
commit 6f11e92801
5 changed files with 16 additions and 0 deletions

View File

@ -7,6 +7,7 @@ package transportmux
import (
"context"
"os"
"sync/atomic"
"syscall"
@ -15,6 +16,7 @@ import (
"net"
"time"
"github.com/kr/pretty"
"github.com/zrepl/zrepl/daemon/logging"
"github.com/zrepl/zrepl/logger"
"github.com/zrepl/zrepl/transport"
@ -151,6 +153,7 @@ func Demux(ctx context.Context, rawListener transport.AuthenticatedListener, lab
rawConn, err := rawListener.Accept(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "transportmux.Demux: rawListener.Accept() returned error: %T %s\n%s\n", err, err, pretty.Sprint(err))
if ctx.Err() != nil {
return
}

View File

@ -10,9 +10,12 @@ import (
"fmt"
"io"
"net"
"os"
"strings"
"time"
"unicode/utf8"
"github.com/kr/pretty"
)
type HandshakeMessage struct {
@ -93,6 +96,7 @@ func (m *HandshakeMessage) Encode() ([]byte, error) {
func (m *HandshakeMessage) DecodeReader(r io.Reader, maxLen int) error {
var lenAndSpace [11]byte
if _, err := io.ReadFull(r, lenAndSpace[:]); err != nil {
fmt.Fprintf(os.Stderr, "HandshakeMessage.DecodeReader error: %T\n%s", err, pretty.Sprint(err))
return hsIOErr(err, "error reading protocol banner length: %s", err)
}
if !utf8.Valid(lenAndSpace[:]) {

View File

@ -2,7 +2,9 @@ package versionhandshake
import (
"context"
"fmt"
"net"
"os"
"time"
"github.com/zrepl/zrepl/transport"
@ -23,6 +25,7 @@ func (c HandshakeConnecter) Connect(ctx context.Context) (transport.Wire, error)
dl = time.Now().Add(c.timeout)
}
if err := DoHandshakeCurrentVersion(conn, dl); err != nil {
fmt.Fprintf(os.Stderr, "HandshakeConnecter error: %T\n\t%s\n\t%v\n\t%#v\n\n", err, err, err, err)
conn.Close()
return nil, err
}

View File

@ -3,7 +3,9 @@ package tls
import (
"context"
"crypto/tls"
"fmt"
"net"
"os"
"github.com/pkg/errors"
@ -48,6 +50,7 @@ func TLSConnecterFromConfig(in *config.TLSConnect) (*TLSConnecter, error) {
func (c *TLSConnecter) Connect(dialCtx context.Context) (transport.Wire, error) {
conn, err := c.dialer.DialContext(dialCtx, "tcp", c.Address)
if err != nil {
fmt.Fprintf(os.Stderr, "tls connecter error %T\n\t%s\n\t%v\n\t%#v\n\n", err, err, err, err)
return nil, err
}
tcpConn := conn.(*net.TCPConn)

View File

@ -4,8 +4,10 @@ import (
"context"
"crypto/tls"
"fmt"
"os"
"time"
"github.com/kr/pretty"
"github.com/pkg/errors"
"github.com/zrepl/zrepl/config"
@ -68,6 +70,7 @@ type tlsAuthListener struct {
func (l tlsAuthListener) Accept(ctx context.Context) (*transport.AuthConn, error) {
tcpConn, tlsConn, cn, err := l.ClientAuthListener.Accept()
if err != nil {
fmt.Fprintf(os.Stderr, "tlsAuthListener.Accept: l.ClientAuthListener.Accept returned error %T %s\n%s\n", err, err, pretty.Sprint(err))
return nil, err
}
if _, ok := l.clientCNs[cn]; !ok {