Add annotation ssl-prefer-server-ciphers.
This commit is contained in:
parent
0e785a0bf2
commit
41d82005ec
8 changed files with 54 additions and 9 deletions
|
|
@ -108,7 +108,7 @@ type Ingress struct {
|
|||
UpstreamVhost string
|
||||
Whitelist ipwhitelist.SourceRange
|
||||
XForwardedPrefix string
|
||||
SSLCiphers string
|
||||
SSLCipher sslcipher.Config
|
||||
Logs log.Config
|
||||
InfluxDB influxdb.Config
|
||||
ModSecurity modsecurity.Config
|
||||
|
|
@ -156,7 +156,7 @@ func NewAnnotationExtractor(cfg resolver.Resolver) Extractor {
|
|||
"UpstreamVhost": upstreamvhost.NewParser(cfg),
|
||||
"Whitelist": ipwhitelist.NewParser(cfg),
|
||||
"XForwardedPrefix": xforwardedprefix.NewParser(cfg),
|
||||
"SSLCiphers": sslcipher.NewParser(cfg),
|
||||
"SSLCipher": sslcipher.NewParser(cfg),
|
||||
"Logs": log.NewParser(cfg),
|
||||
"InfluxDB": influxdb.NewParser(cfg),
|
||||
"BackendProtocol": backendprotocol.NewParser(cfg),
|
||||
|
|
|
|||
|
|
@ -27,13 +27,35 @@ type sslCipher struct {
|
|||
r resolver.Resolver
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
SSLCiphers string
|
||||
SSLPreferServerCiphers string
|
||||
}
|
||||
|
||||
// NewParser creates a new sslCipher annotation parser
|
||||
func NewParser(r resolver.Resolver) parser.IngressAnnotation {
|
||||
return sslCipher{r}
|
||||
}
|
||||
|
||||
// Parse parses the annotations contained in the ingress rule
|
||||
// used to add ssl-ciphers to the server name
|
||||
// used to add ssl-ciphers & ssl-prefer-server-ciphers to the server name
|
||||
func (sc sslCipher) Parse(ing *networking.Ingress) (interface{}, error) {
|
||||
return parser.GetStringAnnotation("ssl-ciphers", ing)
|
||||
config := &Config{}
|
||||
var err error
|
||||
var sslPreferServerCiphers bool
|
||||
|
||||
sslPreferServerCiphers, err = parser.GetBoolAnnotation("ssl-prefer-server-ciphers", ing)
|
||||
if err != nil {
|
||||
config.SSLPreferServerCiphers = ""
|
||||
} else {
|
||||
if sslPreferServerCiphers {
|
||||
config.SSLPreferServerCiphers = "on"
|
||||
} else {
|
||||
config.SSLPreferServerCiphers = "off"
|
||||
}
|
||||
}
|
||||
|
||||
config.SSLCiphers, _ = parser.GetStringAnnotation("ssl-ciphers", ing)
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func TestParse(t *testing.T) {
|
|||
for _, testCase := range testCases {
|
||||
ing.SetAnnotations(testCase.annotations)
|
||||
result, _ := ap.Parse(ing)
|
||||
if result != testCase.expected {
|
||||
if result.SSLCiphers != testCase.expected {
|
||||
t.Errorf("expected %v but returned %v, annotations: %s", testCase.expected, result, testCase.annotations)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1051,8 +1051,9 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
Locations: []*ingress.Location{
|
||||
loc,
|
||||
},
|
||||
SSLPassthrough: anns.SSLPassthrough,
|
||||
SSLCiphers: anns.SSLCiphers,
|
||||
SSLPassthrough: anns.SSLPassthrough,
|
||||
SSLCiphers: anns.SSLCipher.SSLCiphers,
|
||||
SSLPreferServerCiphers: anns.SSLCipher.SSLPreferServerCiphers,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1092,8 +1093,13 @@ func (n *NGINXController) createServers(data []*ingress.Ingress,
|
|||
}
|
||||
|
||||
// only add SSL ciphers if the server does not have them previously configured
|
||||
if servers[host].SSLCiphers == "" && anns.SSLCiphers != "" {
|
||||
servers[host].SSLCiphers = anns.SSLCiphers
|
||||
if servers[host].SSLCiphers == "" && anns.SSLCipher.SSLCiphers != "" {
|
||||
servers[host].SSLCiphers = anns.SSLCipher.SSLCiphers
|
||||
}
|
||||
|
||||
// only add SSLPreferServerCiphers if the server does not have them previously configured
|
||||
if servers[host].SSLPreferServerCiphers == "" && anns.SSLCipher.SSLPreferServerCiphers != "" {
|
||||
servers[host].SSLPreferServerCiphers = anns.SSLCipher.SSLPreferServerCiphers
|
||||
}
|
||||
|
||||
// only add a certificate if the server does not have one previously configured
|
||||
|
|
|
|||
|
|
@ -200,6 +200,9 @@ type Server struct {
|
|||
ServerSnippet string `json:"serverSnippet"`
|
||||
// SSLCiphers returns list of ciphers to be enabled
|
||||
SSLCiphers string `json:"sslCiphers,omitempty"`
|
||||
// SSLPreferServerCiphers indicates that server ciphers should be preferred
|
||||
// over client ciphers when using the SSLv3 and TLS protocols.
|
||||
SSLPreferServerCiphers string `sslPreferServerCiphers,omitempty`
|
||||
// AuthTLSError contains the reason why the access to a server should be denied
|
||||
AuthTLSError string `json:"authTLSError,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,6 +308,9 @@ func (s1 *Server) Equal(s2 *Server) bool {
|
|||
if s1.SSLCiphers != s2.SSLCiphers {
|
||||
return false
|
||||
}
|
||||
if s1.SSLPreferServerCiphers != s2.SSLPreferServerCiphers {
|
||||
return false
|
||||
}
|
||||
if s1.AuthTLSError != s2.AuthTLSError {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue