()
| 35 | } |
| 36 | |
| 37 | func (c *Conn) makeClientHello() (*clientHelloMsg, ecdheParameters, error) { |
| 38 | config := c.config |
| 39 | if len(config.ServerName) == 0 && !config.InsecureSkipVerify { |
| 40 | return nil, nil, errors.New("tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config") |
| 41 | } |
| 42 | |
| 43 | nextProtosLength := 0 |
| 44 | for _, proto := range config.NextProtos { |
| 45 | if l := len(proto); l == 0 || l > 255 { |
| 46 | return nil, nil, errors.New("tls: invalid NextProtos value") |
| 47 | } else { |
| 48 | nextProtosLength += 1 + l |
| 49 | } |
| 50 | } |
| 51 | if nextProtosLength > 0xffff { |
| 52 | return nil, nil, errors.New("tls: NextProtos values too large") |
| 53 | } |
| 54 | |
| 55 | supportedVersions := config.supportedVersions(roleClient) |
| 56 | if len(supportedVersions) == 0 { |
| 57 | return nil, nil, errors.New("tls: no supported versions satisfy MinVersion and MaxVersion") |
| 58 | } |
| 59 | |
| 60 | clientHelloVersion := config.maxSupportedVersion(roleClient) |
| 61 | // The version at the beginning of the ClientHello was capped at TLS 1.2 |
| 62 | // for compatibility reasons. The supported_versions extension is used |
| 63 | // to negotiate versions now. See RFC 8446, Section 4.2.1. |
| 64 | if clientHelloVersion > VersionTLS12 { |
| 65 | clientHelloVersion = VersionTLS12 |
| 66 | } |
| 67 | |
| 68 | hello := &clientHelloMsg{ |
| 69 | vers: clientHelloVersion, |
| 70 | compressionMethods: []uint8{compressionNone}, |
| 71 | random: make([]byte, 32), |
| 72 | sessionId: make([]byte, 32), |
| 73 | ocspStapling: true, |
| 74 | scts: true, |
| 75 | serverName: hostnameInSNI(config.ServerName), |
| 76 | supportedCurves: config.curvePreferences(), |
| 77 | supportedPoints: []uint8{pointFormatUncompressed}, |
| 78 | secureRenegotiationSupported: true, |
| 79 | alpnProtocols: config.NextProtos, |
| 80 | supportedVersions: supportedVersions, |
| 81 | } |
| 82 | |
| 83 | if c.handshakes > 0 { |
| 84 | hello.secureRenegotiation = c.clientFinished[:] |
| 85 | } |
| 86 | |
| 87 | preferenceOrder := cipherSuitesPreferenceOrder |
| 88 | if !hasAESGCMHardwareSupport { |
| 89 | preferenceOrder = cipherSuitesPreferenceOrderNoAES |
| 90 | } |
| 91 | configCipherSuites := config.cipherSuites() |
| 92 | hello.cipherSuites = make([]uint16, 0, len(configCipherSuites)) |
| 93 | |
| 94 | for _, suiteId := range preferenceOrder { |
no test coverage detected