|
| 1 | +''' |
| 2 | +''' |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | + |
| 19 | +Test.Summary = ''' |
| 20 | +Test SNI configuration server_groups_list |
| 21 | +''' |
| 22 | +# The groups function was added in OpenSSL 1.1.1 |
| 23 | +Test.SkipUnless(Condition.HasOpenSSLVersion("1.1.1")) |
| 24 | + |
| 25 | +# Define default ATS |
| 26 | +ts = Test.MakeATSProcess("ts", enable_tls=True) |
| 27 | +server = Test.MakeOriginServer("server", ssl=True) |
| 28 | + |
| 29 | +request_header = {"headers": "GET / HTTP/1.1\r\n\r\n", "timestamp": "1469733493.993", "body": ""} |
| 30 | +response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": "foo ok"} |
| 31 | +server.addResponse("sessionlog.json", request_header, response_header) |
| 32 | + |
| 33 | +# add ssl materials like key, certificates for the server |
| 34 | +ts.addSSLfile("ssl/server.pem") |
| 35 | +ts.addSSLfile("ssl/server.key") |
| 36 | + |
| 37 | +# Need no remap rules. Everything should be processed by sni |
| 38 | + |
| 39 | +# Make sure the TS server certs are different from the origin certs |
| 40 | +ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key') |
| 41 | + |
| 42 | +ts.Disk.records_config.update( |
| 43 | + { |
| 44 | + 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), |
| 45 | + 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir), |
| 46 | + 'proxy.config.ssl.client.CA.cert.path': '{0}'.format(ts.Variables.SSLDir), |
| 47 | + 'proxy.config.diags.debug.enabled': 1, |
| 48 | + 'proxy.config.diags.debug.tags': 'ssl_sni', |
| 49 | + }) |
| 50 | + |
| 51 | +ts.Disk.sni_yaml.AddLines( |
| 52 | + [ |
| 53 | + 'sni:', |
| 54 | + '- fqdn: aaa.com', |
| 55 | + ' server_groups_list: X25519MLKEM768', |
| 56 | + ' valid_tls_versions_in: [ TLSv1_3 ]', |
| 57 | + ' server_TLSv1_3_cipher_suites: TLS_AES_256_GCM_SHA384', |
| 58 | + '- fqdn: bbb.com', |
| 59 | + ' server_groups_list: x25519', |
| 60 | + ' valid_tls_versions_in: [ TLSv1_2 ]', |
| 61 | + ' server_cipher_suite: ECDHE-RSA-AES256-GCM-SHA384', |
| 62 | + '- fqdn: ccc.com', |
| 63 | + ' server_groups_list: ABC123', |
| 64 | + ' valid_tls_versions_in: [ TLSv1_2 ]', |
| 65 | + ' server_cipher_suite: ECDHE-RSA-AES256-GCM-SHA384', |
| 66 | + ]) |
| 67 | + |
| 68 | +tr = Test.AddTestRun("Test 0: x25519") |
| 69 | +tr.Processes.Default.StartBefore(server) |
| 70 | +tr.Processes.Default.StartBefore(Test.Processes.ts) |
| 71 | +tr.MakeCurlCommand( |
| 72 | + "-v --ciphers ECDHE-RSA-AES256-GCM-SHA384 --resolve 'bbb.com:{0}:127.0.0.1' -k https://bbb.com:{0}".format( |
| 73 | + ts.Variables.ssl_port)) |
| 74 | +tr.ReturnCode = 0 |
| 75 | +tr.StillRunningAfter = ts |
| 76 | +ts.Disk.traffic_out.Content += Testers.ContainsExpression( |
| 77 | + "Setting groups list from server_groups_list to x25519", "Should log setting the server groups") |
| 78 | +tr.Processes.Default.Streams.all = Testers.IncludesExpression( |
| 79 | + f"SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384 / x25519", "Curl should log using x25519 in the SSL connection") |
| 80 | + |
| 81 | +tr = Test.AddTestRun("Test 1: fail") |
| 82 | +tr.MakeCurlCommand( |
| 83 | + "-v --ciphers ECDHE-RSA-AES256-GCM-SHA384 --resolve 'ccc.com:{0}:127.0.0.1' -k https://ccc.com:{0}".format( |
| 84 | + ts.Variables.ssl_port)) |
| 85 | +# The error code is 35, which indicates there was a ssl connection error |
| 86 | +tr.ReturnCode = 35 |
| 87 | +tr.StillRunningAfter = ts |
| 88 | +tr.StillRunningAfter = server |
| 89 | +ts.Disk.diags_log.Content = Testers.ContainsExpression( |
| 90 | + "ERROR: Invalid server_groups_list: ABC123", "Curl attempt should have failed") |
| 91 | + |
| 92 | +# Hybrid ECDH PQ key exchange TLS groups were added in OpenSSL 3.5 |
| 93 | +if Condition.HasOpenSSLVersion("3.5.0"): |
| 94 | + tr = Test.AddTestRun("Test 2: X25519MLKEM768") |
| 95 | + tr.MakeCurlCommand( |
| 96 | + "-v --tls13-ciphers TLS_AES_256_GCM_SHA384 --resolve 'aaa.com:{0}:127.0.0.1' -k https://aaa.com:{0}".format( |
| 97 | + ts.Variables.ssl_port)) |
| 98 | + tr.ReturnCode = 0 |
| 99 | + tr.StillRunningAfter = ts |
| 100 | + ts.Disk.traffic_out.Content += Testers.ContainsExpression( |
| 101 | + "Setting groups list from server_groups_list to X25519MLKEM768", "Should log setting the server groups") |
| 102 | + tr.Processes.Default.Streams.all = Testers.IncludesExpression( |
| 103 | + f"SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519MLKEM768", |
| 104 | + f"Curl should log using X25519MLKEM768 in the SSL connection") |
0 commit comments