Skip to content

Commit 23c4cce

Browse files
pranavsriram8YashwantGohokar
authored andcommitted
Skip Cipher Suite Update on Listeners and Backendsets when Unspecified
1 parent 0de2288 commit 23c4cce

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

pkg/cloudprovider/providers/oci/load_balancer_util.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,14 @@ func getSSLConfigurationChanges(actual *client.GenericSslConfigurationDetails, d
440440
if toBool(actual.VerifyPeerCertificate) != toBool(desired.VerifyPeerCertificate) {
441441
sslConfigurationChanges = append(sslConfigurationChanges, fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:VerifyPeerCertificate", toBool(actual.VerifyPeerCertificate), toBool(desired.VerifyPeerCertificate)))
442442
}
443-
if toString(actual.CipherSuiteName) != toString(desired.CipherSuiteName) {
444-
sslConfigurationChanges = append(sslConfigurationChanges, fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:CipherSuiteName", toString(actual.CipherSuiteName), toString(desired.CipherSuiteName)))
445-
}
446-
if !reflect.DeepEqual(actual.Protocols, desired.Protocols) {
447-
sslConfigurationChanges = append(sslConfigurationChanges, fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:Protocols", strings.Join(actual.Protocols, ","), strings.Join(desired.Protocols, ",")))
443+
444+
if desired.CipherSuiteName != nil && len(*desired.CipherSuiteName) != 0 {
445+
if toString(actual.CipherSuiteName) != toString(desired.CipherSuiteName) {
446+
sslConfigurationChanges = append(sslConfigurationChanges, fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:CipherSuiteName", toString(actual.CipherSuiteName), toString(desired.CipherSuiteName)))
447+
}
448+
if !reflect.DeepEqual(actual.Protocols, desired.Protocols) {
449+
sslConfigurationChanges = append(sslConfigurationChanges, fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:Protocols", strings.Join(actual.Protocols, ","), strings.Join(desired.Protocols, ",")))
450+
}
448451
}
449452

450453
return sslConfigurationChanges

pkg/cloudprovider/providers/oci/load_balancer_util_test.go

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,25 +2155,54 @@ func TestGetSSLConfigurationChanges(t *testing.T) {
21552155
{
21562156
name: "Protocol Changed",
21572157
desired: client.GenericSslConfigurationDetails{
2158-
Protocols: []string{"TLSv1.2"},
2158+
CipherSuiteName: common.String("value"),
2159+
Protocols: []string{"TLSv1.2"},
2160+
},
2161+
actual: client.GenericSslConfigurationDetails{
2162+
CipherSuiteName: common.String("value"),
21592163
},
2160-
actual: client.GenericSslConfigurationDetails{},
21612164
expected: []string{
21622165
fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:Protocols", "", "TLSv1.2"),
21632166
},
21642167
},
21652168
{
21662169
name: "TLS Protocol Changed",
21672170
desired: client.GenericSslConfigurationDetails{
2168-
Protocols: []string{"TLSv1.1", "TLSv1.2"},
2171+
CipherSuiteName: common.String("value"),
2172+
Protocols: []string{"TLSv1.1", "TLSv1.2"},
21692173
},
21702174
actual: client.GenericSslConfigurationDetails{
2171-
Protocols: []string{"TLSv1.1", "TLSv1.2", "TLSv1.3"},
2175+
CipherSuiteName: common.String("value"),
2176+
Protocols: []string{"TLSv1.1", "TLSv1.2", "TLSv1.3"},
21722177
},
21732178
expected: []string{
21742179
fmt.Sprintf(changeFmtStr, "Listener:SSLConfiguration:Protocols", "", "TLSv1.2"),
21752180
},
21762181
},
2182+
{
2183+
name: "Empty ciphersuite test",
2184+
desired: client.GenericSslConfigurationDetails{
2185+
CipherSuiteName: common.String(""),
2186+
Protocols: []string{"TLSv1.1", "TLSv1.2"},
2187+
},
2188+
actual: client.GenericSslConfigurationDetails{
2189+
CipherSuiteName: common.String("value"),
2190+
Protocols: []string{"TLSv1.1", "TLSv1.2", "TLSv1.3"},
2191+
},
2192+
expected: []string{},
2193+
},
2194+
{
2195+
name: "Default scenario, nil value",
2196+
desired: client.GenericSslConfigurationDetails{
2197+
CipherSuiteName: nil,
2198+
Protocols: []string{"TLSv1.1", "TLSv1.2"},
2199+
},
2200+
actual: client.GenericSslConfigurationDetails{
2201+
CipherSuiteName: common.String("value"),
2202+
Protocols: []string{"TLSv1.1", "TLSv1.2", "TLSv1.3"},
2203+
},
2204+
expected: []string{},
2205+
},
21772206
}
21782207

21792208
for _, tt := range testCases {

0 commit comments

Comments
 (0)