3 # Normal tlsproxy tests.
5 # Copyright (C) 2011 Simon Ruderich
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Handle empty $srcdir.
22 [ "x$srcdir" = x ] && srcdir=.
27 # Create necessary files.
29 $srcdir/../src/tlsproxy-setup >/dev/null 2>/dev/null
32 ../src/tlsproxy -d2 4711 >/dev/null &
33 server --x509certfile $srcdir/server.pem \
34 --x509keyfile $srcdir/server-key.pem
39 client unknown-host 80 - && abort
41 test_no_invalid_certificate
43 echo missing proxy and server certificate
44 client localhost 4712 invalid || abort
46 test_invalid_certificate
48 # Create the proxy certificate.
49 $srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \
50 >/dev/null 2>/dev/null
51 rm -f certificate-localhost-server.pem
53 echo missing server certificate
54 client localhost 4712 invalid || abort
56 test_invalid_certificate
58 # Create the proxy and server certificate.
59 $srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \
60 >/dev/null 2>/dev/null
62 echo normal connection
63 # 'localhost' is the CN of tlsproxy's certificate.
64 client localhost 4712 localhost || abort
66 test_no_invalid_certificate
69 # Stop server and try a "MITM" with a bad certificate.
72 server --x509certfile $srcdir/server-bad.pem \
73 --x509keyfile $srcdir/server-key.pem
75 rm -f certificate-localhost-proxy.pem certificate-localhost-server.pem
78 echo mitm invalid hostname
79 client unknown-host 80 - && abort
81 test_no_invalid_certificate
83 echo mitm missing proxy and server certificate
84 client localhost 4712 invalid || abort
86 test_invalid_certificate
88 # Create the proxy certificate.
89 $srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \
90 >/dev/null 2>/dev/null
91 rm -f certificate-localhost-server.pem
93 echo mitm missing server certificate
94 client localhost 4712 invalid || abort
96 test_invalid_certificate
98 # Create the proxy and server certificate.
99 $srcdir/../src/tlsproxy-add localhost $srcdir/server.pem \
100 >/dev/null 2>/dev/null
102 echo mitm normal connection
103 client localhost 4712 invalid || abort
104 test_proxy_successful
105 test_invalid_certificate