| 1 |
package tlsutil |
| 2 |
|
| 3 |
import ( |
| 4 |
"crypto/tls" |
| 5 |
|
| 6 |
"github.com/smallstep/cli/crypto/x509util" |
| 7 |
) |
| 8 |
|
| 9 |
|
| 10 |
|
| 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 |
|
| 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 |
} |