Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions agent-manager/updates/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"crypto/tls"
"net/http"
"os"
"time"

"github.com/gin-contrib/gzip"
"github.com/threatwinds/go-sdk/catcher"

"github.com/gin-gonic/gin"
Expand All @@ -23,7 +23,6 @@ func ServeDependencies() {
r := gin.New()
r.Use(
gin.Recovery(),
gzip.Gzip(gzip.DefaultCompression),
)

r.NoRoute(notFound)
Expand All @@ -33,20 +32,31 @@ func ServeDependencies() {

loadedCert, err := tls.LoadX509KeyPair(config.CertPath, config.CertKeyPath)
if err != nil {
catcher.Error("failed to load TLS credentials", err, map[string]any{"process": "agent-manager"})
_ = catcher.Error("failed to load TLS credentials", err, map[string]any{"process": "agent-manager"})
time.Sleep(5 * time.Second)
os.Exit(1)
}

tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
Certificates: []tls.Certificate{loadedCert},
MinVersion: tls.VersionTLS12,
MaxVersion: tls.VersionTLS13,
CipherSuites: []uint16{
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
// TLS 1.2 secure cipher suites - RSA key exchange
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
// TLS 1.2 secure cipher suites - ECDSA key exchange (for ECDSA certificates)
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
},
CurvePreferences: []tls.CurveID{
tls.X25519, // Modern and fast
tls.CurveP256, // NIST P-256
tls.CurveP384, // NIST P-384
tls.CurveP521, // NIST P-521
},

PreferServerCipherSuites: true,
}

server := &http.Server{
Expand All @@ -57,7 +67,7 @@ func ServeDependencies() {

catcher.Info("Starting HTTP server on port 8080", map[string]any{"process": "agent-manager"})
if err := server.ListenAndServeTLS("", ""); err != nil {
catcher.Error("error starting HTTP server", err, map[string]any{"process": "agent-manager"})
_ = catcher.Error("error starting HTTP server", err, map[string]any{"process": "agent-manager"})
return
}
}
Expand Down
Loading