[PD1] FIXED TLS Handshake
This commit is contained in:
parent
1cb81d2279
commit
4cf7880e57
5 changed files with 77 additions and 22 deletions
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
|
||||
type ClientTLSConfigProvider interface {
|
||||
GetTLSConfig() *tls.Config
|
||||
GetClientTLSConfig() *tls.Config
|
||||
}
|
||||
|
||||
type Client[T any] struct {
|
||||
|
@ -15,9 +15,9 @@ type Client[T any] struct {
|
|||
}
|
||||
|
||||
func NewClient[T any](clientTLSConfigProvider ClientTLSConfigProvider) Client[T] {
|
||||
dialConn, err := tls.Dial("tcp", "localhost:8080", clientTLSConfigProvider.GetTLSConfig())
|
||||
dialConn, err := tls.Dial("tcp", "localhost:8080", clientTLSConfigProvider.GetClientTLSConfig())
|
||||
if err != nil {
|
||||
log.Panicln("Could not open connection to server",err)
|
||||
log.Panicln("Server connection error:\n",err)
|
||||
}
|
||||
conn := NewConnection[T](dialConn)
|
||||
return Client[T]{Connection: conn}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type ServerTLSConfigProvider interface {
|
||||
GetTLSConfig() *tls.Config
|
||||
GetServerTLSConfig() *tls.Config
|
||||
}
|
||||
|
||||
type Server[T any] struct {
|
||||
|
@ -18,7 +18,7 @@ type Server[T any] struct {
|
|||
|
||||
func NewServer[T any](serverTLSConfigProvider ServerTLSConfigProvider, port int) Server[T] {
|
||||
|
||||
listener, err := tls.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port), serverTLSConfigProvider.GetTLSConfig())
|
||||
listener, err := tls.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port), serverTLSConfigProvider.GetServerTLSConfig())
|
||||
if err != nil {
|
||||
panic("Server could not bind to address")
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func (s *Server[T]) ListenLoop() {
|
|||
if !ok {
|
||||
panic("Connection is not a TLS connection")
|
||||
}
|
||||
fmt.Println(tlsConn)
|
||||
tlsConn.Handshake()
|
||||
|
||||
state := tlsConn.ConnectionState()
|
||||
if len(state.PeerCertificates) == 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue