Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: net/data/ssl/scripts/client_authentication/run-forwarded-test-server.sh

Issue 12220104: Wire up SSL client authentication for OpenSSL/Android through the net/ stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/bin/bash
2 #
3
4 # Ensure script exits if commands fail.
5 set -e
6
7 # Scrappy script to test client certificate support on an Android device.
8 PROGDIR=$(dirname "$0")
9 PROGNAME=$(basename "$0")
10
11 HELP=
12 VERBOSE=0
13 BUILDTYPE=${BUILDTYPE:-Release}
14 FORWARDER_SOCKET=openssl_server_forwarder
15 FORWARDER_HOST_PORT=5000
16 HOST_SERVER_PORT=4433
17 DEVICE_SERVER_PORT=$HOST_SERVER_PORT
18
19 for OPT; do
20 case $OPT in
21 -v|--verbose)
22 VERBOSE=$(( $VERBOSE + 1 ))
23 ;;
24 -q|--quiet)
25 VERBOSE=$(( $VERBOSE - 1 ))
26 ;;
27 --help|-h|-?)
28 HELP=true
29 ;;
30 --release)
31 BUILDTYPE=Release
32 ;;
33 --debug)
34 BUILDTYPE=Debug
35 ;;
36 -*)
37 echo "ERROR: Unsupported option: $OPT, see --help for details."
38 exit 1
39 ;;
40 *)
41 echo "ERROR: This script doesn't take parameters. See --help."
42 exit 1
43 esac
44 done
45
46 if [ "$HELP" ]; then
47 echo "\
48 Usage: $PROGNAME [options]
49
50 This program is used to start a HTTPS server on your local machine, after
51 setting up a reverse network redirection on an attached Android device.
52
53 Start this script, then on the device, open the following URL in your
54 browser:
55
56 https://localhost:$DEVICE_SERVER_PORT
57
58 This shall prompt you for an installed client certificate.
59
60 Valid options are:
61 --help|-h|-? Print this message.
62 --verbose Increase verbosity.
63 --quiet Decrease verbosity.
64 --release Assume BUILDTYPE=Release.
65 --debug Assume BUILDTYPE=Debug.
66 -v Same as --verbose.
67 -q Same as --quiet.
68 "
69 exit 0
70 fi
71
72 run () {
73 if [ "$VERBOSE" -ge 1 ]; then
74 echo "COMMAND: $@"
75 fi
76 "$@"
77 }
78
79 # Return the PID of a given program running on the device.
80 # $1: Program full path
81 get_pid_of () {
82 $ADB shell ps | awk '$9 ~ "'$1'" { print $2; }'
83 }
84
85 CHROME_OUT=$(cd "$PROGDIR/../../../../../out" && pwd)
86 echo "CHROME_OUT=$CHROME_OUT"
87 if [ ! -d "$CHROME_OUT" ]; then
88 echo "ERROR: Can't find: $CHROME_OUT"
89 exit 1
90 fi
91
92 # Configuration defaults:
93 BUILDTYPE=${BUILDTYPE:-Release}
94
95 FORWARDER_SOCKET=openssl_server_forwarder
96 FORWARDER_HOST_PORT=5000
97 HOST_SERVER_PORT=4433
98 DEVICE_SERVER_PORT=$HOST_SERVER_PORT
99
100 HOST_FORWARDER=host_forwarder
101 DEVICE_FORWARDER=device_forwarder
102 DATA_TMP=/data/local/tmp
103
104 ADB=${ADB:-adb}
105
106 # Kill any existing forwarder.
107 DEVICE_PID=$(get_pid_of $DATA_TMP/$DEVICE_FORWARDER)
108 if [ "$DEVICE_PID" ]; then
109 echo "Killing existing device forwarder instance."
110 run adb shell kill -9 "$DEVICE_PID"
111 fi
112
113 # Push the forwarder to the device, and start it.
114 run $ADB push $CHROME_OUT/$BUILDTYPE/$DEVICE_FORWARDER \
115 $DATA_TMP/$DEVICE_FORWARDER
116 run $ADB forward tcp:$FORWARDER_HOST_PORT localabstract:$FORWARDER_SOCKET
117 run $ADB shell $DATA_TMP/$DEVICE_FORWARDER $FORWARDER_SOCKET
118 run sleep 1
119
120 # Check that the device forwarder was started.
121 if [ -z "$($ADB shell ps | grep -e $DEVICE_FORWARDER)" ]; then
122 echo "Could not start device forwarder!?"
123 exit 1
124 fi
125
126 # Now send a command to it to reverse-forward the server ports
127 run $CHROME_OUT/$BUILDTYPE/$HOST_FORWARDER \
128 "$FORWARDER_HOST_PORT:$DEVICE_SERVER_PORT:$HOST_SERVER_PORT:127.0.0.1"
129
130 # localhost:4433. The server will be accessible for www connections and
131 # will require a client certificate issued by Client Auth Test Root 1.
132 run openssl s_server \
133 -accept $HOST_SERVER_PORT \
134 -cert $PROGDIR/out/root_1.pem \
135 -key $PROGDIR/out/root_1.key \
136 -www \
137 -Verify 5 \
138 -CAfile $PROGDIR/out/root_1.pem
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698