moonchen commented on code in PR #13712:
URL: https://github.com/apache/trafficserver/pull/13712#discussion_r4076261942


##########
tests/gold_tests/tls/tls_dual_cert_default_client.py:
##########
@@ -0,0 +1,55 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information regarding
+#  copyright ownership.  The ASF licenses this file to you under
+#  the Apache License, Version 2.0 (the "License"); you may not use
+#  this file except in compliance with the License.  You may obtain
+#  a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+"""Probe default and named certificate selection with restricted signature 
algorithms."""
+
+import re
+import subprocess
+import sys
+
+
+def main(port: int) -> None:
+    cases = 0
+    for version in ('tls1_2', 'tls1_3'):
+        for servername, common_name in ((None, 'foo.com'), ('unknown.example', 
'foo.com'), ('one.com', 'group.com')):
+            for sigalg, signature in (('rsa_pss_rsae_sha256', 
r'(RSA-PSS|rsa_pss_)'), ('ecdsa_secp256r1_sha256',
+                                                                               
        r'(ECDSA|ecdsa_)')):
+                command = [
+                    'openssl',
+                    's_client',
+                    '-brief',
+                    '-connect',
+                    f'127.0.0.1:{port}',
+                    f'-{version}',
+                    '-sigalgs',
+                    sigalg,
+                ]
+                command += ['-servername', servername] if servername else 
['-noservername']
+                if version == 'tls1_2':
+                    auth = 'RSA' if sigalg.startswith('rsa_') else 'ECDSA'
+                    command += ['-cipher', f'ECDHE-{auth}-AES128-GCM-SHA256']
+                result = subprocess.run(command, input='', 
capture_output=True, text=True, timeout=10)

Review Comment:
   The timeout applies separately to each handshake, not to the full loop. 
Keeping the bounded wait; there is no timeout failure here.



##########
tests/gold_tests/tls/tls_dual_cert_default_client.py:
##########
@@ -0,0 +1,55 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information regarding
+#  copyright ownership.  The ASF licenses this file to you under
+#  the Apache License, Version 2.0 (the "License"); you may not use
+#  this file except in compliance with the License.  You may obtain
+#  a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+"""Probe default and named certificate selection with restricted signature 
algorithms."""
+
+import re
+import subprocess
+import sys
+
+
+def main(port: int) -> None:
+    cases = 0
+    for version in ('tls1_2', 'tls1_3'):
+        for servername, common_name in ((None, 'foo.com'), ('unknown.example', 
'foo.com'), ('one.com', 'group.com')):
+            for sigalg, signature in (('rsa_pss_rsae_sha256', 
r'(RSA-PSS|rsa_pss_)'), ('ecdsa_secp256r1_sha256',
+                                                                               
        r'(ECDSA|ecdsa_)')):
+                command = [
+                    'openssl',
+                    's_client',
+                    '-brief',
+                    '-connect',
+                    f'127.0.0.1:{port}',
+                    f'-{version}',
+                    '-sigalgs',
+                    sigalg,
+                ]
+                command += ['-servername', servername] if servername else 
['-noservername']
+                if version == 'tls1_2':
+                    auth = 'RSA' if sigalg.startswith('rsa_') else 'ECDSA'
+                    command += ['-cipher', f'ECDHE-{auth}-AES128-GCM-SHA256']
+                result = subprocess.run(command, input='', 
capture_output=True, text=True, timeout=10)
+                output = result.stdout + result.stderr
+                label = f'{version}, SNI={servername}, sigalg={sigalg}'
+                if (result.returncode != 0 or re.search(rf'Signature type: 
{signature}', output) is None or

Review Comment:
   The helper uses `-brief`, whose summary prints `Signature type:`. `Peer 
signature type:` belongs to the verbose output. The regex already accepts both 
the legacy names and the newer `rsa_pss_` / `ecdsa_` names.



##########
tests/gold_tests/tls/tls_dual_cert_default.test.py:
##########
@@ -0,0 +1,41 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information regarding
+#  copyright ownership.  The ASF licenses this file to you under
+#  the Apache License, Version 2.0 (the "License"); you may not use
+#  this file except in compliance with the License.  You may obtain
+#  a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+"""Select default RSA and EC certificates independently of their order."""
+
+import os
+import shlex
+import sys
+
+Test.Summary = __doc__
+Test.SkipUnless(Condition.HasOpenSSLVersion('1.1.1'))
+
+for order in ('rsa_ec', 'ec_rsa'):
+    tr = 
Test.ATSReplayTest(replay_file=f'replay/dual_cert_default_{order}.replay.yaml')
+    ts = tr.Processes[f'ts_{order}']
+    for name in ('signed-foo', 'signed-foo-ec', 'signed-san', 'signed-san-ec'):
+        ts.addSSLfile(f'ssl/{name}.pem')
+        ts.addSSLfile(f'ssl/{name}.key')
+    ts.Disk.records_config.update(
+        {
+            'proxy.config.ssl.server.cert.path': ts.Variables.SSLDir,
+            'proxy.config.ssl.server.private_key.path': ts.Variables.SSLDir,
+        })
+    # Proxy Verifier checks the HTTP exchange. Use s_client afterward to 
constrain
+    # signature algorithms, which the replay client cannot configure.
+    helper = shlex.quote(os.path.join(Test.TestDirectory, 
'tls_dual_cert_default_client.py'))
+    tr.Processes.Default.Command += f' && {shlex.quote(sys.executable)} 
{helper} {ts.Variables.ssl_port}'
+    tr.Processes.Default.Streams.All += Testers.ContainsExpression(
+        'PASS: 12 certificate selections', f'Both key types work with 
certificate order {order}')

Review Comment:
   The count is intentional: it checks that all 12 combinations ran for each 
certificate order. Changes to the matrix should update this expectation along 
with the helper.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to