Skip to content

Commit

Permalink
feat: add tls debug info
Browse files Browse the repository at this point in the history
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
  • Loading branch information
QuentinN42 committed Oct 17, 2023
1 parent 079fdd2 commit 699a704
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/roundtrip/roudtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func HandleRequest(protoReq *proto.Request) *proto.Response {
logger.Debug("Url : %v", protoReq.Url)
dns(protoReq.Url)
traceroute(protoReq.Url)
tls(protoReq.Url)
}

logger.Debug("Sending request (%v)", protoReq.Correlation)
Expand Down
34 changes: 34 additions & 0 deletions pkg/roundtrip/tls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package roundtrip

import (
"net/url"

cryptotls "crypto/tls"

"github.com/Escape-Technologies/repeater/pkg/logger"
)

func tls(input string) {
logger.Debug("TLS debug info")
u, err := url.Parse(input)
if err != nil {
logger.Error("ERROR parsing url : %v", err)
return
}
conf := &cryptotls.Config{
InsecureSkipVerify: true,
}

conn, err := cryptotls.Dial("tcp", u.Host, conf)
if err != nil {
logger.Error("Error in Dial %v", err)
return
}
defer conn.Close()
certs := conn.ConnectionState().PeerCertificates
for _, cert := range certs {
logger.Debug("Issuer Name: %s", cert.Issuer)
logger.Debug("Expiry: %s", cert.NotAfter.Format("2006-January-02"))
logger.Debug("Common Name: %s", cert.Issuer.CommonName)
}
}

0 comments on commit 699a704

Please sign in to comment.