-
Notifications
You must be signed in to change notification settings - Fork 0
/
eggdrop_ssl_config.bats
195 lines (168 loc) · 7.76 KB
/
eggdrop_ssl_config.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
teardown() {
ps x|grep "[e]ggdrop "
if [ $? -eq 0 ]; then
pkill eggdrop
fi
if [ -e $HOME/eggdrop/tempuser.user ]; then
rm $HOME/eggdrop/tempsuer.user
fi
}
@test "Eggdrop setup" {
run cp $WORK_DIR/tests/eggdrop_ssl_config.* $HOME/eggdrop
[ $status -eq 0 ]
run cp $WORK_DIR/tests/cmd_accept.tcl $HOME/eggdrop
[ $status -eq 0 ]
# run cp $WORK_DIR/tests/eggdrop.{key,crt} $HOME/eggdrop
# [ $status -eq 0 ]
cp $HOME/eggdrop/eggdrop.key $HOME/eggdrop/eggdropz.key
cp $HOME/eggdrop/eggdrop.crt $HOME/eggdrop/eggdropz.crt
cd $HOME/eggdrop
}
@test "Eggdrop runs/uses proper SSL keys" {
skip
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\set ssl-certificate \"eggdropz.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"eggdropz.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
[ $status -eq 0 ]
## Check values of running bot...
}
@test "Eggdrop dies if user-specified .key file is missing/incorrect" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\set ssl-certificate \"eggdrop.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"sdfsdf.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
echo $output
[[ "$output" == *"Unable to load TLS private key (ssl-privatekey config setting)"* ]]
[ $status -eq 1 ]
}
@test "Eggdrop dies if user-specified .crt file is missing/incorrect" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\set ssl-certificate \"sdfsdf.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"eggdrop.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
[[ "$output" == *"Unable to load TLS certificate (ssl-certificate config setting"* ]]
[ $status -eq 1 ]
}
@test "Eggdrop runs if SSL .key and .crt file are commented" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\#set ssl-certificate \"eggdrop.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\#set ssl-privatekey \"eggdrop.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
[ $status -eq 0 ]
}
@test "Eggdrop runs if SSL .key and .crt file are set to \"\"" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\set ssl-certificate \"\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
[ $status -eq 0 ]
}
@test "Eggdrop dies if .crt is specified/present, but .key is commented" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\set ssl-certificate \"eggdrop.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\#set ssl-privatekey \"\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf 2>&1
[[ "$output" == *"ERROR: TLS: ssl-certificate set but ssl-privatekey unset. Both must be set to use a certificate, or unset both to disable."* ]]
[ $status -eq 1 ]
}
@test "Eggdrop dies if .key is specified/present, but .crt is commented" {
cd $HOME/eggdrop
sed -i '/set ssl-certificate/c\#set ssl-certificate \"\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"eggdrop.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf 2>&1
echo $output
[[ "$output" == *"ERROR: TLS: ssl-privatekey set but ssl-certificate unset. Both must be set to use a certificate, or unset both to disable."* ]]
[ $status -eq 1 ]
}
@test "Eggdrop dies if key file empty" {
cd $HOME/eggdrop
touch badkey.key
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"badkey.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-certificate/c\set ssl-certificate \"eggdrop.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
rm badkey.key
[[ ${output} == *"ERROR: TLS: unable to load private key from badkey.key: error:"* ]]
[ $status -eq 1 ]
}
@test "Eggdrop dies if key/crt file do not match" {
cd $HOME/eggdrop
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"eggdrop_ssl_config.badpair.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-certificate/c\set ssl-certificate \"eggdrop.crt\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop eggdrop_ssl_config.conf
echo $output
[[ ${output} == *"ERROR: TLS: unable to load private key from eggdrop_ssl_config.badpair.key: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch"* ]]
[ $status -eq 1 ]
}
@test "Eggdrop disconnects on no matching protocols" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "GEO"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-privatekey/c\set ssl-privatekey \"eggdrop.key\"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${ssltext}
echo ${ssltext}|grep "tls_construct_client_hello:no protocols available";
[ $status -eq 0 ]
}
@test "Eggdrop chooses proper SSL/TLS protocol, Eggdrop higher than server" {
# Freenode offers 1.0 and 1.2
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "TLSv1 TLSv1.1 TLSv1.2 TLSv1.3"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${ssltext}
echo ${ssltext}|grep "TLS: cipher used:"|grep TLSv1.2;
[ $status -eq 0 ]
}
@test "Eggdrop chooses proper SSL/TLS protocol, Eggdrop same as server" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "TLSv1 TLSv1.1 TLSv1.2"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${ssltext}|grep "TLS: cipher used:"| grep TLSv1.2;
[ $status -eq 0 ]
}
@test "Eggdrop chooses proper SSL/TLS protocol, Eggdrop lower than server" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "TLSv1 TLSv1.1"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${ssltext}|grep "TLS: cipher used:"| grep TLSv1.1;
echo $output
[ $status -eq 0 ]
}
@test "Eggdrop uses specified SSL/TLS cipher" {
cd $HOME/eggdrop
sed -i '/set ssl-ciphers/c\set ssl-ciphers "ECDHE-RSA-AES256-SHA"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${ssltext}|grep "TLS: cipher used: ECDHE-RSA-AES256-SHA"
[ $status -eq 0 ]
}
@test "Eggdrop disconnects on required cipher stronger than supported protocol" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "TLSv1"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-ciphers/c\set ssl-ciphers "ECDHE-RSA-AES256-GCM-SHA384"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo $output
echo ${ssltext}|grep "SSL routines:ssl_cipher_list_to_bytes:no ciphers available"
}
@test "Eggdrop disconnects on required cipher weaker/disallowed by supported protocol" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-protocols "TLSv1.2"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-ciphers/c\set ssl-ciphers "TLS_RSA_WITH_AES_128_CBC_SHA"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo $output
echo ${ssltext}|grep "SSL routines:ssl_cipher_list_to_bytes:no ciphers available"
}
@test "Eggdrop warns on incorrect DHParam file" {
cd $HOME/eggdrop
sed -i '/set ssl-protocols/c\set ssl-ciphers "DEFAULT"' $HOME/eggdrop/eggdrop_ssl_config.conf
sed -i '/set ssl-dhparam/c\set ssl-dhparam "foo.pem"' $HOME/eggdrop/eggdrop_ssl_config.conf
run ./eggdrop -nt eggdrop_ssl_config.conf
ssltext=${output}
echo ${output}
echo ${ssltext} |grep "ERROR: TLS: unable to open foo.pem: No such file or directory"
}