Repository: secdev/scapy

Issue:
Custom array of Extension
### Brief description

Can't send my array of Extension in Client Hello packet SSL.

### Scapy version

2.4.5rc1.dev245

### Python version

3.10.4

### Operating system

Windows 10

### Additional environment information

_No response_

### How to reproduce

1. Install Tomcat>9.0.50 and setup sslProtocol="TLS" in server.xml.
2. Try to connect with server by python script. 

Hello, I'm trying to send my extension in a hello client package. I do this with the following code:

```python
from scapy.layers.tls.handshake import *
from scapy.layers.tls.automaton_cli import TLSClientAutomaton
from scapy.layers.tls.extensions import *
supported_groups = ["secp384r1", "x448"]
supported_groups.append("x25519")
ext1 = [
  TLS_Ext_ExtendedMasterSecret(len=0),
  TLS_Ext_SupportedVersion_CH(versions=["TLS 1.3"]),
  TLS_Ext_RenegotiationInfo(renegotiated_connection=0),
  TLS_Ext_SupportedGroups(groups=supported_groups)
  ]
a = TLS13ClientHello(ciphers=[0x1301, 0x1302, 0x1303, 0x1304, 0x1305, 0x1306], ext=ext1)
t = TLSClientAutomaton(server="192.168.252.132", dport=443, client_hello=a, version="tls13")
t.run()
```

But in Client Hello i saw this Extensions:

![image](https://user-images.githubusercontent.com/3701803/169791185-6cf3de34-ab63-4d5e-bdc7-776039d37c83.png)

And in console output i saw "Missing TLS 1.3 EncryptedExtensions message!":

![image](https://user-images.githubusercontent.com/3701803/169792239-ca88a9de-b517-488d-a5ef-dae320275c97.png)

I already read [this issue](https://github.com/secdev/scapy/issues/2673), but my server is Tomcat with `sslProtocol="TLS"` and when i try to connect with it in TLS v1.2 I get Handshake Error.

Question: How can I send my arrya of Extension?

### Actual result

_No response_

### Expected result

_No response_

### Related resources

_No response_


Discussion:
This could be related to https://github.com/secdev/scapy/issues/4247


Resolving patch:
diff --git a/scapy/layers/tls/automaton_cli.py b/scapy/layers/tls/automaton_cli.py
--- a/scapy/layers/tls/automaton_cli.py
+++ b/scapy/layers/tls/automaton_cli.py
@@ -292,16 +292,16 @@ def should_add_ClientHello(self):
             p = self.client_hello
         else:
             p = TLSClientHello()
-        ext = []
-        # Add TLS_Ext_SignatureAlgorithms for TLS 1.2 ClientHello
-        if self.cur_session.advertised_tls_version == 0x0303:
-            ext += [TLS_Ext_SignatureAlgorithms(sig_algs=["sha256+rsa"])]
-        # Add TLS_Ext_ServerName
-        if self.server_name:
-            ext += TLS_Ext_ServerName(
-                servernames=[ServerName(servername=self.server_name)]
-            )
-        p.ext = ext
+            ext = []
+            # Add TLS_Ext_SignatureAlgorithms for TLS 1.2 ClientHello
+            if self.cur_session.advertised_tls_version == 0x0303:
+                ext += [TLS_Ext_SignatureAlgorithms(sig_algs=["sha256+rsa"])]
+            # Add TLS_Ext_ServerName
+            if self.server_name:
+                ext += TLS_Ext_ServerName(
+                    servernames=[ServerName(servername=self.server_name)]
+                )
+            p.ext = ext
         self.add_msg(p)
         raise self.ADDED_CLIENTHELLO()
 


Test patch: