@@ -97,19 +97,23 @@ type Options struct {
9797 //
9898 // Diagnostics.
9999 //
100- logging.LoggingOptions // Logging configuration.
101- Tracing bool // Enables emitting traces.
102- HealthChecking bool // Enables health checking.
103- MetricsPort int // The metrics port exposed by EPP. (TODO: uint16)
104- GRPCHealthPort int // The port used for gRPC liveness and readiness probes. (TODO: uint16)
105- EnablePprof bool // Enables pprof handlers.
106- CertPath string // The path to the certificate for secure serving.
107- EnableCertReload bool // Enables certificate reloading of the certificates specified in --cert-path.
108- SecureServing bool // Enables secure serving.
109- MetricsEndpointAuth bool // Enables authentication and authorization of the metrics endpoint.
110- MetricsClientCAFile string // PEM CA that requires a verified client cert on the metrics endpoint.
111- MetricsCertDir string // Directory with the metrics server certificates that enables metrics TLS.
112- EnableGRPCStreamMetrics bool // Enables ext_proc gRPC stream metrics (in-flight gauge, hold duration, completions counter by code).
100+ logging.LoggingOptions // Logging configuration.
101+ Tracing bool // Enables emitting traces.
102+ HealthChecking bool // Enables health checking.
103+ MetricsPort int // The metrics port exposed by EPP. (TODO: uint16)
104+ GRPCHealthPort int // The port used for gRPC liveness and readiness probes. (TODO: uint16)
105+ EnablePprof bool // Enables pprof handlers.
106+ CertPath string // The path to the certificate for secure serving.
107+ EnableCertReload bool // Enables certificate reloading of the certificates specified in --cert-path.
108+ SecureServing bool // Enables secure serving.
109+ TLSMinVersion string // Minimum TLS version for secure serving (e.g., VersionTLS12, VersionTLS13).
110+ TLSCipherSuites []string // TLS cipher suites (Go crypto/tls names). Only effective for TLS 1.2 and below.
111+ tlsMinVersionValue uint16 // Parsed TLS min version value.
112+ tlsCipherSuiteValues []uint16 // Parsed TLS cipher suite values.
113+ MetricsEndpointAuth bool // Enables authentication and authorization of the metrics endpoint.
114+ MetricsClientCAFile string // PEM CA that requires a verified client cert on the metrics endpoint.
115+ MetricsCertDir string // Directory with the metrics server certificates that enables metrics TLS.
116+ EnableGRPCStreamMetrics bool // Enables ext_proc gRPC stream metrics (in-flight gauge, hold duration, completions counter by code).
113117 //
114118 // Configuration.
115119 //
@@ -213,6 +217,10 @@ func (opts *Options) AddFlags(fs *pflag.FlagSet) {
213217 fs .BoolVar (& opts .EnableGRPCStreamMetrics , "enable-grpc-stream-metrics" , opts .EnableGRPCStreamMetrics ,
214218 "Enables ext_proc gRPC stream metrics (in-flight gauge, hold-duration histogram, completions counter by code)." )
215219 fs .BoolVar (& opts .SecureServing , "secure-serving" , opts .SecureServing , "Enables secure serving." )
220+ fs .StringVar (& opts .TLSMinVersion , "tls-min-version" , opts .TLSMinVersion ,
221+ "Minimum TLS version for secure serving (e.g., VersionTLS12, VersionTLS13)." )
222+ fs .StringSliceVar (& opts .TLSCipherSuites , "tls-cipher-suites" , opts .TLSCipherSuites ,
223+ "Comma-separated list of TLS cipher suites for secure serving (Go crypto/tls names, e.g., TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256). Only effective for TLS 1.2 and below; TLS 1.3 cipher suites are not configurable." )
216224 fs .BoolVar (& opts .MetricsEndpointAuth , "metrics-endpoint-auth" , opts .MetricsEndpointAuth ,
217225 "Enables authentication and authorization of the metrics endpoint." )
218226 fs .StringVar (& opts .MetricsClientCAFile , "metrics-client-ca-file" , opts .MetricsClientCAFile ,
@@ -285,6 +293,21 @@ func (opts *Options) Complete() error {
285293 }
286294 }
287295
296+ if opts .TLSMinVersion != "" {
297+ v , err := parseTLSVersion (opts .TLSMinVersion )
298+ if err != nil {
299+ return fmt .Errorf ("invalid tls-min-version %q: %w" , opts .TLSMinVersion , err )
300+ }
301+ opts .tlsMinVersionValue = v
302+ }
303+ if len (opts .TLSCipherSuites ) > 0 {
304+ suites , err := parseCipherSuites (opts .TLSCipherSuites )
305+ if err != nil {
306+ return fmt .Errorf ("invalid tls-cipher-suites: %w" , err )
307+ }
308+ opts .tlsCipherSuiteValues = suites
309+ }
310+
288311 // Complete logging options.
289312 return opts .LoggingOptions .Complete ()
290313}
@@ -391,3 +414,50 @@ func removeDuplicatePorts(ports []int) []int {
391414 }
392415 return unique
393416}
417+
418+ // TLSMinVersionValue returns the parsed uint16 TLS min version.
419+ func (opts * Options ) TLSMinVersionValue () uint16 {
420+ return opts .tlsMinVersionValue
421+ }
422+
423+ // TLSCipherSuiteValues returns the parsed uint16 TLS cipher suite IDs.
424+ func (opts * Options ) TLSCipherSuiteValues () []uint16 {
425+ return opts .tlsCipherSuiteValues
426+ }
427+
428+ var tlsVersions = map [string ]uint16 {
429+ "VersionTLS10" : tls .VersionTLS10 ,
430+ "VersionTLS11" : tls .VersionTLS11 ,
431+ "VersionTLS12" : tls .VersionTLS12 ,
432+ "VersionTLS13" : tls .VersionTLS13 ,
433+ }
434+
435+ func parseTLSVersion (s string ) (uint16 , error ) {
436+ if v , ok := tlsVersions [s ]; ok {
437+ return v , nil
438+ }
439+ return 0 , fmt .Errorf ("unknown TLS version %q; supported values: VersionTLS10, VersionTLS11, VersionTLS12, VersionTLS13" , s )
440+ }
441+
442+ func parseCipherSuites (names []string ) ([]uint16 , error ) {
443+ byName := make (map [string ]uint16 )
444+ for _ , cs := range tls .CipherSuites () {
445+ byName [cs .Name ] = cs .ID
446+ }
447+ for _ , cs := range tls .InsecureCipherSuites () {
448+ byName [cs .Name ] = cs .ID
449+ }
450+ ids := make ([]uint16 , 0 , len (names ))
451+ for _ , name := range names {
452+ name = strings .TrimSpace (name )
453+ if name == "" {
454+ continue
455+ }
456+ id , ok := byName [name ]
457+ if ! ok {
458+ return nil , fmt .Errorf ("unknown cipher suite %q" , name )
459+ }
460+ ids = append (ids , id )
461+ }
462+ return ids , nil
463+ }
0 commit comments