Skip to content

Commit 5daec06

Browse files
authored
Merge pull request #18 from ninjadq/master
Enhance: add minversion and cipher for tls
2 parents 9b8ec34 + 3e9154f commit 5daec06

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

pkg/http/api/server.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package api
22

33
import (
44
"context"
5+
"crypto/tls"
6+
"net/http"
7+
58
"github.com/goharbor/harbor-scanner-clair/pkg/etc"
69
log "github.com/sirupsen/logrus"
7-
"net/http"
810
)
911

1012
type Server struct {
@@ -43,6 +45,24 @@ func (s *Server) listenAndServe() error {
4345
}).Debug("Starting API server with TLS")
4446
return s.server.ListenAndServeTLS(s.config.TLSCertificate, s.config.TLSKey)
4547
}
48+
49+
s.server.TLSConfig = &tls.Config{
50+
PreferServerCipherSuites: true,
51+
CurvePreferences: []tls.CurveID{
52+
tls.CurveP256,
53+
tls.X25519,
54+
},
55+
MinVersion: tls.VersionTLS12,
56+
CipherSuites: []uint16{
57+
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
58+
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
59+
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
60+
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
61+
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
62+
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
63+
},
64+
}
65+
4666
log.WithField("addr", s.config.Addr).Warn("Starting API server without TLS")
4767
return s.server.ListenAndServe()
4868
}

0 commit comments

Comments
 (0)