[PD1] Added certificates and fixed a few things
This commit is contained in:
parent
b7023329de
commit
1cb81d2279
28 changed files with 596 additions and 54 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
type ServerTLSConfigProvider interface {
|
||||
GetTLSConfigServer() *tls.Config
|
||||
GetTLSConfig() *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.GetTLSConfigServer())
|
||||
listener, err := tls.Listen("tcp", fmt.Sprintf("0.0.0.0:%d", port), serverTLSConfigProvider.GetTLSConfig())
|
||||
if err != nil {
|
||||
panic("Server could not bind to address")
|
||||
}
|
||||
|
@ -39,9 +39,11 @@ func (s *Server[T]) ListenLoop() {
|
|||
if !ok {
|
||||
panic("Connection is not a TLS connection")
|
||||
}
|
||||
fmt.Println(tlsConn)
|
||||
|
||||
state := tlsConn.ConnectionState()
|
||||
if len(state.PeerCertificates) == 0 {
|
||||
fmt.Println(state.PeerCertificates)
|
||||
log.Panicln("Client did not provide a certificate")
|
||||
}
|
||||
conn := NewConnection[T](tlsConn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue