Update against new nodee conn type (#2245)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2022-07-08 14:14:17 -04:00
1 parent 6b48346bf3
commit 1596ff3d1c
4 files changed
+29 -6

No files matched your search

@@ -9,6 +9,7 @@ import (
"github.com/hashicorp/boundary/internal/observability/event"
nodee "github.com/hashicorp/nodeenrollment"
"github.com/hashicorp/nodeenrollment/protocol"
)
// tempError is an error that satisfies the temporary error interface that is
@@ -76,7 +77,20 @@ func (m *interceptingListener) Accept() (net.Conn, error) {
return nil, newTempError(err)
}
tlsConn := conn.(*tls.Conn)
var tlsConn *tls.Conn
switch c := conn.(type) {
case *protocol.Conn:
// If we so choose, at this point we can pull out the client's
// NextProtos with c.ClientNextProtos
tlsConn = c.Conn
case *tls.Conn:
tlsConn = c
default:
err := fmt.Errorf("unknown connection type %T received", c)
event.WriteError(ctx, op, err)
return nil, newTempError(err)
}
switch {
case nodee.ContainsKnownAlpnProto(tlsConn.ConnectionState().NegotiatedProtocol):
keyId, err := nodee.KeyIdFromPkix(tlsConn.ConnectionState().PeerCertificates[0].SubjectKeyId)