Skip to content

Commit

Permalink
Make compression methods, ocsp stapling and supported EC points confi…
Browse files Browse the repository at this point in the history
…gurable in Config (#372)

Co-authored-by: Zakir Durumeric <[email protected]>
  • Loading branch information
esuwu and zakird authored Nov 6, 2023
1 parent a55ea7b commit 293c098
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
11 changes: 11 additions & 0 deletions tls/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,17 @@ type Config struct {
// supported for ECDHE key exchanges
ExplicitCurvePreferences bool

// EC Point Formats. Specifies what compressed points the client supports
SupportedPoints []uint8

// Online Certificate Status Protocol (OCSP) stapling,
// formally knows as TLS Certificate Status Request.
// If this option enabled, the certificate status won't be checked
NoOcspStapling bool

// Specifies what compression methods the client supports
CompressionMethods []uint8

// If enabled, specifies the signature and hash algorithms to be accepted by
// a server, or sent by a client
SignatureAndHashes []SigAndHash
Expand Down
20 changes: 17 additions & 3 deletions tls/handshake_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,28 @@ func (c *Conn) clientHandshake() error {
return errors.New("tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config")
}

supportedPoints := []uint8{pointFormatUncompressed}
if c.config.SupportedPoints != nil {
supportedPoints = c.config.SupportedPoints
}
oscpStapling := true
if c.config.NoOcspStapling {
oscpStapling = false
}

compressionMethods := []uint8{compressionNone}
if c.config.CompressionMethods != nil {
compressionMethods = c.config.CompressionMethods
}

hello = &clientHelloMsg{
vers: c.config.maxVersion(),
compressionMethods: []uint8{compressionNone},
compressionMethods: compressionMethods,
random: make([]byte, 32),
ocspStapling: true,
ocspStapling: oscpStapling,
serverName: c.config.ServerName,
supportedCurves: c.config.curvePreferences(),
supportedPoints: []uint8{pointFormatUncompressed},
supportedPoints: supportedPoints,
nextProtoNeg: len(c.config.NextProtos) > 0,
secureRenegotiation: true,
alpnProtocols: c.config.NextProtos,
Expand Down

0 comments on commit 293c098

Please sign in to comment.