Skip to content

Commit a489e54

Browse files
cleaned up x11vnc tests and new code
x11vnc tests needed some scripts broken out into separate files and use of a shared script. The new code for displaying rsa certificates needed some fixes and extra comments
1 parent a13b09e commit a489e54

8 files changed

Lines changed: 341 additions & 354 deletions

File tree

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/bin/bash
2+
3+
SCRIPTS_DIR="$GITHUB_WORKSPACE/.github/scripts/x11vnc"
4+
5+
killall x11vnc > /dev/null 2> /dev/null
6+
killall Xvfb > /dev/null 2> /dev/null
7+
8+
X11VNC_TEST_FAIL=0
9+
10+
11+
# CA / cert generation
12+
13+
14+
echo -e "\n\nTesting -sslGenCA\n" > x11vnc_test.log
15+
16+
$SCRIPTS_DIR/x11vnc_sslgenca.exp >> x11vnc_test.log 2>> x11vnc_test.log
17+
18+
if [ $? -eq 0 ] && [ -f "ca-dir/CA/cacert.pem" ] && [ -f "ca-dir/CA/private/cakey.pem" ]
19+
then
20+
echo "[ PASSED ] -sslGenCA"
21+
else
22+
echo "[ FAILED ] -sslGenCA"
23+
X11VNC_TEST_FAIL=1
24+
fi
25+
26+
27+
echo -e "\n\nTesting -sslGenCert client\n" >> x11vnc_test.log
28+
29+
$SCRIPTS_DIR/x11vnc_sslgencert_client.exp >> x11vnc_test.log 2>> x11vnc_test.log
30+
31+
if [ $? -eq 0 ] && [ -f "ca-dir/clients/wolf.pem" ] && [ -f "ca-dir/clients/wolf.crt" ]
32+
then
33+
echo "[ PASSED ] -sslGenCert client"
34+
else
35+
echo "[ FAILED ] -sslGenCert client"
36+
X11VNC_TEST_FAIL=1
37+
fi
38+
39+
40+
echo -e "\n\nTesting -sslGenCert server\n" >> x11vnc_test.log
41+
42+
$SCRIPTS_DIR/x11vnc_sslgencert_server.exp >> x11vnc_test.log 2>> x11vnc_test.log
43+
44+
if [ $? -eq 0 ] && [ -f "ca-dir/server-wolf.pem" ] && [ -f "ca-dir/server-wolf.crt" ]
45+
then
46+
echo "[ PASSED ] -sslGenCert server"
47+
else
48+
echo "[ FAILED ] -sslGenCert server"
49+
X11VNC_TEST_FAIL=1
50+
fi
51+
52+
53+
echo -e "\n\nTesting -sslCertInfo\n" >> x11vnc_test.log
54+
55+
OPENSSL_CONF='' OPENSSL_MODULES='' timeout 1 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info_ossl.txt
56+
timeout 1 x11vnc -sslCertInfo ca-dir/server-wolf.pem > cert_info.txt
57+
58+
if [ $? -eq 0 ] && diff -y cert_info.txt cert_info_ossl.txt >> x11vnc_test.log 2>> x11vnc_test.log \
59+
&& cat cert_info.txt >> x11vnc_test.log
60+
then
61+
echo "[ PASSED ] -sslCertInfo"
62+
else
63+
echo "[ FAILED ] -sslCertInfo"
64+
X11VNC_TEST_FAIL=1
65+
fi
66+
67+
68+
echo -e "\n\nTesting -sslEncKey\n" >> x11vnc_test.log
69+
70+
$SCRIPTS_DIR/x11vnc_sslenckey.exp >> x11vnc_test.log 2>> x11vnc_test.log
71+
72+
if [ $? -eq 0 ] && grep -q "BEGIN ENCRYPTED PRIVATE KEY" ca-dir/server-wolf.pem
73+
then
74+
echo "[ PASSED ] -sslEncKey"
75+
else
76+
echo "[ FAILED ] -sslEncKey"
77+
X11VNC_TEST_FAIL=1
78+
fi
79+
80+
81+
# SSL
82+
83+
84+
# Setup Xvfb, which is a purely virtual display, i.e., humans cannot see it
85+
# but it works the same as any other X server
86+
Xvfb :0 -screen 0 100x100x8 2>> x11vnc_test.log &
87+
sleep 2
88+
89+
90+
# Testing with SSL will use the TLSNone security type
91+
echo -e "\n\nTesting -ssl handshake, authentication, initialization...\n" >> x11vnc_test.log
92+
93+
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log`
94+
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
95+
96+
timeout 10 vncviewer -GnuTLSPriority=LEGACY -DesktopSize=0 -display :0 -log *:stderr:100 localhost::$PORT 2> client.log
97+
98+
if grep -Eq "SSL: handshake with helper process[[0-9]+] succeeded" server.log \
99+
&& grep -q "CConnection: Authentication success" client.log \
100+
&& grep -q "CConnection: initialisation done" client.log
101+
then
102+
echo "[ PASSED ] -ssl handshake, authentication, initialization"
103+
else
104+
echo "[ FAILED ] -ssl handshake, authentication, initialization"
105+
X11VNC_TEST_FAIL=1
106+
fi
107+
killall x11vnc > /dev/null 2> /dev/null
108+
cat server.log client.log >> x11vnc_test.log
109+
110+
111+
# Testing with a password changes the security type from TLSNone to TLSVnc
112+
echo -e "\n\nTesting -ssl with a password...\n" >> x11vnc_test.log
113+
114+
x11vnc -storepasswd wolfprov passwd 2>> x11vnc_test.log
115+
116+
PORT=`x11vnc -ssl TMP -display :0 -localhost -bg -o server.log -rfbauth passwd`
117+
PORT=`echo "$PORT" | grep -m 1 "PORT=" | sed -e 's/PORT=//'`
118+
119+
timeout 10 vncviewer -GnuTLSPriority=LEGACY -DesktopSize=0 -display :0 -passwd passwd -log *:stderr:100 localhost::$PORT 2> client.log
120+
121+
if grep -Eq "SSL: handshake with helper process[[0-9]+] succeeded" server.log \
122+
&& grep -q "CConnection: Authentication success" client.log \
123+
&& grep -q "CConnection: initialisation done" client.log
124+
then
125+
echo "[ PASSED ] -ssl with a password"
126+
else
127+
echo "[ FAILED ] -ssl with a password"
128+
X11VNC_TEST_FAIL=1
129+
fi
130+
killall x11vnc > /dev/null 2> /dev/null
131+
cat server.log client.log >> x11vnc_test.log
132+
133+
134+
# HTTP HTTPS
135+
136+
137+
echo "<html><body>Use WolfSSL!</body></html>" > index.html
138+
139+
140+
PORT=`x11vnc -ssl TMP -display :0 -localhost -httpdir . -https 5678 -bg -o server.log`
141+
PORT=`echo "$PORT" | grep -m 1 -Eo "http://localhost:[0-9]+" server.log | sed -e 's/http:\/\/localhost://'`
142+
143+
echo -e "\n\nTesting -https with http...\n" >> x11vnc_test.log
144+
145+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "http://localhost:$PORT/index.html" >> x11vnc_test.log
146+
then
147+
echo "[ PASSED ] -https with an http request"
148+
else
149+
echo "[ FAILED ] -https with an http request"
150+
X11VNC_TEST_FAIL=1
151+
fi
152+
153+
154+
echo -e "\n\nTesting -https with https...\n" >> x11vnc_test.log
155+
156+
if OPENSSL_CONF='' OPENSSL_MODULES='' curl -ks "https://localhost:5678/index.html" >> x11vnc_test.log
157+
then
158+
echo "[ PASSED ] -https with an https request"
159+
else
160+
echo "[ FAILED ] -https with an https request"
161+
X11VNC_TEST_FAIL=1
162+
fi
163+
164+
killall x11vnc > /dev/null 2> /dev/null
165+
killall Xvfb > /dev/null 2> /dev/null
166+
cat server.log >> x11vnc_test.log
167+
168+
$GITHUB_WORKSPACE/.github/scripts/check-workflow-result.sh $X11VNC_TEST_FAIL "$WOLFPROV_FORCE_FAIL_STR" x11vnc
169+
X11VNC_TEST_FAIL=$?
170+
171+
if [[ $X11VNC_TEST_FAIL -eq 1 ]]; then cat x11vnc_test.log; fi
172+
173+
exit $X11VNC_TEST_FAIL
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/expect
2+
3+
set timeout 1
4+
5+
spawn x11vnc -sslEncKey ca-dir/server-wolf.pem
6+
7+
sleep 1
8+
9+
# verify encryption is desired
10+
expect {
11+
"Protect key with a passphrase?" { send "y\r" }
12+
eof { exit 1 }
13+
}
14+
15+
# supply password
16+
expect {
17+
"Enter pass phrase:" { send "wolfprov\r" }
18+
eof { exit 1 }
19+
}
20+
expect "Verifying" { send "wolfprov\r" }
21+
22+
expect eof
23+
exit 0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/expect
2+
3+
set timeout 1
4+
5+
spawn x11vnc -sslGenCA ca-dir
6+
7+
sleep 1
8+
9+
# provide password and verify
10+
expect {
11+
"PEM" { send "wolfprov\r" }
12+
eof { exit 1 }
13+
}
14+
expect "PEM" { send "wolfprov\r" }
15+
16+
# provide CA information
17+
expect "Country Name" { send "US\r" }
18+
expect "State" { send "montana\r" }
19+
expect "Locality" { send "bozeman\r" }
20+
expect "Organization" { send "wolfssl\r" }
21+
expect "Organizational" { send "wolfssl\r" }
22+
expect "Common" { send "wolfserver\r" }
23+
expect "Email" { send "wolf@server.com\r" }
24+
25+
# if CA creation has succeeded then the enter key will be expected
26+
expect {
27+
"Enter" { send "\r" }
28+
eof { exit 1 }
29+
}
30+
31+
expect eof
32+
exit 0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/expect
2+
3+
set timeout 1
4+
5+
# generate a cert for the client
6+
spawn x11vnc -ssldir ca-dir -sslGenCert client wolf
7+
8+
sleep 1
9+
10+
# provide CA information
11+
expect {
12+
"Country Name" { send "US\r" }
13+
eof { exit 1 }
14+
}
15+
expect "State" { send "montana\r" }
16+
expect "Locality" { send "bozeman\r" }
17+
expect "Organization" { send "wolfssl\r" }
18+
expect "Organizational" { send "wolfssl\r" }
19+
expect "Common" { send "wolfclient\r" }
20+
expect "Email" { send "wolf@client.com\r" }
21+
22+
# challenge password and company name
23+
expect "challenge" { send "wolfprov\r" }
24+
expect "company" { send "wolfssl\r" }
25+
26+
# create the cert
27+
expect "passphrase" { send "n\r" }
28+
expect "pass phrase" { send "wolfprov\r" }
29+
expect "Sign" { send "y\r" }
30+
expect "commit" { send "y\r" }
31+
32+
# if cert creation has succeeded then the enter key will be expected
33+
expect {
34+
"Enter" { send "\r" }
35+
eof { exit 1 }
36+
}
37+
38+
expect eof
39+
exit 0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/expect
2+
3+
set timeout 1
4+
5+
# generate a cert for the server
6+
spawn x11vnc -ssldir ca-dir -sslGenCert server wolf
7+
8+
sleep 1
9+
10+
# provide CA information
11+
expect {
12+
"Country Name" { send "US\r" }
13+
eof { exit 1 }
14+
}
15+
expect "State" { send "montana\r" }
16+
expect "Locality" { send "bozeman\r" }
17+
expect "Organization" { send "wolfssl\r" }
18+
expect "Organizational" { send "wolfssl\r" }
19+
expect "Common" { send "wolfserver\r" }
20+
expect "Email" { send "wolf@server.com\r" }
21+
22+
# challenge password and company name
23+
expect "challenge" { send "wolfprov\r" }
24+
expect "company" { send "wolfssl\r" }
25+
26+
# create the cert
27+
expect "passphrase" { send "n\r" }
28+
expect "pass phrase" { send "wolfprov\r" }
29+
expect "Sign" { send "y\r" }
30+
expect "commit" { send "y\r" }
31+
32+
# if cert creation has succeeded then the enter key will be expected
33+
expect {
34+
"Enter" { send "\r" }
35+
eof { exit 1 }
36+
}
37+
38+
expect eof
39+
exit 0

0 commit comments

Comments
 (0)