1#!/usr/bin/env python
2
3## This file is part of Scapy
4## This program is published under a GPLv2 license
5
6"""
7Basic TLS server. A preferred ciphersuite may be provided as first argument.
8
9For instance, "sudo ./server_simple.py c014" will start a server accepting
10any TLS client connection. If provided, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
11will be preferred to any other suite the client might propose.
12"""
13
14import os
15import sys
16
17basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),"../../"))
18sys.path=[basedir]+sys.path
19
20from scapy.layers.tls.automaton_srv import TLSServerAutomaton
21
22
23if len(sys.argv) == 2:
24    pcs = int(sys.argv[1], 16)
25else:
26    pcs = None
27
28t = TLSServerAutomaton(mycert=basedir+'/test/tls/pki/srv_cert.pem',
29                       mykey=basedir+'/test/tls/pki/srv_key.pem',
30                       preferred_ciphersuite=pcs)
31t.run()
32
33