fix tls version annotation (#1652)

This commit is contained in:
澄潭
2025-01-08 15:31:39 +08:00
committed by GitHub
parent 4733af849d
commit 6820a06a99

View File

@@ -15,8 +15,8 @@
package annotations package annotations
import ( import (
"strings"
"fmt" "fmt"
"strings"
networking "istio.io/api/networking/v1alpha3" networking "istio.io/api/networking/v1alpha3"
gatewaytool "istio.io/istio/pkg/config/gateway" gatewaytool "istio.io/istio/pkg/config/gateway"
@@ -143,7 +143,7 @@ func (d downstreamTLS) ApplyGateway(gateway *networking.Gateway, config *Ingress
func needDownstreamTLS(annotations Annotations) bool { func needDownstreamTLS(annotations Annotations) bool {
return annotations.HasASAP(sslCipher) || return annotations.HasASAP(sslCipher) ||
annotations.HasASAP(authTLSSecret)|| annotations.HasASAP(authTLSSecret) ||
annotations.HasASAP(annotationMinTLSVersion) || annotations.HasASAP(annotationMinTLSVersion) ||
annotations.HasASAP(annotationMaxTLSVersion) annotations.HasASAP(annotationMaxTLSVersion)
} }
@@ -151,14 +151,13 @@ func needDownstreamTLS(annotations Annotations) bool {
func convertTLSVersion(version string) (networking.ServerTLSSettings_TLSProtocol, error) { func convertTLSVersion(version string) (networking.ServerTLSSettings_TLSProtocol, error) {
switch version { switch version {
case "TLSv1.0": case "TLSv1.0":
return networking.ServerTLSSettings_TLSV1_0 , nil return networking.ServerTLSSettings_TLSV1_0, nil
case "TLSv1.1": case "TLSv1.1":
return networking.ServerTLSSettings_TLSV1_1 , nil return networking.ServerTLSSettings_TLSV1_1, nil
case "TLSv1.2": case "TLSv1.2":
return networking.ServerTLSSettings_TLSV1_2 , nil return networking.ServerTLSSettings_TLSV1_2, nil
case "TLSv1.3": case "TLSv1.3":
default: return networking.ServerTLSSettings_TLSV1_3, nil
return networking.ServerTLSSettings_TLS_AUTO, fmt.Errorf("invalid TLS version: %s. Valid values are: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3", version)
} }
return networking.ServerTLSSettings_TLS_AUTO, fmt.Errorf("unreachable code, but required by compiler") return networking.ServerTLSSettings_TLS_AUTO, fmt.Errorf("invalid TLS version: %s. Valid values are: TLSv1.0, TLSv1.1, TLSv1.2, TLSv1.3", version)
} }