[PD1] Fixed checking certificate NotAfter and NotBefore dates

This commit is contained in:
Afonso Franco 2024-04-28 23:55:03 +01:00
parent 4ea8315aed
commit 91bc887ba5
Signed by: afonso
SSH key fingerprint: SHA256:aiLbdlPwXKJS5wMnghdtod0SPy8imZjlVvCyUX9DJNk
4 changed files with 38 additions and 6 deletions

View file

@ -32,19 +32,23 @@ func (s *Server[T]) ListenLoop() {
for {
listenerConn, err := s.listener.Accept()
if err != nil {
log.Fatalln("Server could not accept connection")
log.Println("Server could not accept connection")
continue
}
tlsConn, ok := listenerConn.(*tls.Conn)
if !ok {
log.Fatalln("Connection is not a TLS connection")
log.Println("Connection is not a TLS connection")
continue
}
if err := tlsConn.Handshake(); err != nil {
log.Fatalln(err)
log.Println(err)
continue
}
state := tlsConn.ConnectionState()
if len(state.PeerCertificates) == 0 {
log.Fatalln("Client did not provide a certificate")
log.Println("Client did not provide a certificate")
continue
}
conn := NewConnection[T](tlsConn)
s.C <- conn