Skip to content

Commit

Permalink
Merge pull request #18 from ninjadq/master
Browse files Browse the repository at this point in the history
Enhance: add minversion and cipher for tls
  • Loading branch information
ninjadq authored Apr 14, 2020
2 parents 9b8ec34 + 3e9154f commit 5daec06
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/http/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package api

import (
"context"
"crypto/tls"
"net/http"

"github.com/goharbor/harbor-scanner-clair/pkg/etc"
log "github.com/sirupsen/logrus"
"net/http"
)

type Server struct {
Expand Down Expand Up @@ -43,6 +45,24 @@ func (s *Server) listenAndServe() error {
}).Debug("Starting API server with TLS")
return s.server.ListenAndServeTLS(s.config.TLSCertificate, s.config.TLSKey)
}

s.server.TLSConfig = &tls.Config{
PreferServerCipherSuites: true,
CurvePreferences: []tls.CurveID{
tls.CurveP256,
tls.X25519,
},
MinVersion: tls.VersionTLS12,
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
},
}

log.WithField("addr", s.config.Addr).Warn("Starting API server without TLS")
return s.server.ListenAndServe()
}
Expand Down

0 comments on commit 5daec06

Please sign in to comment.