]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/crypto/tls/handshake_client_tls13.go
[dev.boringcrypto] all: merge commit 57c115e1 into dev.boringcrypto
[gostls13.git] / src / crypto / tls / handshake_client_tls13.go
index 1405d6811f3e3eb387b83934cbd8d757e7ee7c2d..c7989867f5637b99f41268dec35188ff1208934a 100644 (file)
@@ -400,17 +400,11 @@ func (hs *clientHandshakeStateTLS13) readServerParameters() error {
        }
        hs.transcript.Write(encryptedExtensions.marshal())
 
-       if encryptedExtensions.alpnProtocol != "" {
-               if len(hs.hello.alpnProtocols) == 0 {
-                       c.sendAlert(alertUnsupportedExtension)
-                       return errors.New("tls: server advertised unrequested ALPN extension")
-               }
-               if mutualProtocol([]string{encryptedExtensions.alpnProtocol}, hs.hello.alpnProtocols) == "" {
-                       c.sendAlert(alertUnsupportedExtension)
-                       return errors.New("tls: server selected unadvertised ALPN protocol")
-               }
-               c.clientProtocol = encryptedExtensions.alpnProtocol
+       if err := checkALPN(hs.hello.alpnProtocols, encryptedExtensions.alpnProtocol); err != nil {
+               c.sendAlert(alertUnsupportedExtension)
+               return err
        }
+       c.clientProtocol = encryptedExtensions.alpnProtocol
 
        return nil
 }