Debian Codegraph @

crypto/tlsutil/options.go

raw symbols SCIP
1 package tlsutil
2
3 import (
4 "crypto/tls"
5
6 "github.com/smallstep/cli/crypto/x509util"
7 )
8
9 // TLSOptions represents the TLS options that can be specified on *tls.Config
10 // types to configure HTTPS servers and clients.
11 type TLSOptions struct {
12 CipherSuites x509util.CipherSuites `json:"cipherSuites" step:"cipherSuites"`
13 MinVersion x509util.TLSVersion `json:"minVersion" step:"minVersion"`
14 MaxVersion x509util.TLSVersion `json:"maxVersion" step:"maxVersion"`
15 Renegotiation bool `json:"renegotiation" step:"renegotiation"`
16 }
17
18 // TLSConfig returns the tls.Config equivalent of the TLSOptions.
19 func (t *TLSOptions) TLSConfig() *tls.Config {
20 var rs tls.RenegotiationSupport
21 if t.Renegotiation {
22 rs = tls.RenegotiateFreelyAsClient
23 } else {
24 rs = tls.RenegotiateNever
25 }
26
27 return &tls.Config{
28 CipherSuites: t.CipherSuites.Value(),
29 MinVersion: t.MinVersion.Value(),
30 MaxVersion: t.MaxVersion.Value(),
31 Renegotiation: rs,
32 }
33 }