3 # This is a helper script, wraps any command and sets up environment for
5 # Autossl.so is an LD_PRELOAD-ed library which intercepts network connections
6 # and upgrade them to TLS.
8 # This helper script provides convenience logic to help you type less when
9 # using it with common simple commands, like "wget <URL>". You probably
10 # use it only with simple commands anyways, so this convenience logic is
11 # opt-out. Turn it off by set AUTOSSL_CONVENIENCE=off in your invoking
14 # As part of the convenience it (1) replaces https url-like command line
15 # arguments to http (to let autossl.so intercept the plain connection and
16 # upgrade it back to https during the connection) and (2) find domain
17 # names in command line arguments and passes appropriate "-servername"
18 # parameter to the underlaying openssl command.
20 # Set OPENSSL_EXTRA_ARGS environment variable to pass more parameters to openssl.
22 # It has an embedding port mapping which contains common plain:tls port
23 # pairs for a given protocol, but you can extend it by setting splace
24 # separated "plain:tls" port number pairs in AUTOSSL_TLS_PORT_MAP env
27 # See autossl.so docs for more info.
31 echo "Usage: autossl <COMMAND> [<ARGUMENTS>]"
33 echo " AUTOSSL_BACKEND - which program to use as a upgrade-to-TLS helper. supported: openssl (default), stunnel"
34 echo " AUTOSSL_CONVENIENCE - if set to \"off\", don't try to guess SNI servername"
35 echo " AUTOSSL_SILENT - less diagnostical messages"
36 echo " AUTOSSL_UPGRADE_PORTS - space-delimited list of port numbers which autossl should work on (default 80)"
37 echo " AUTOSSL_UPGRADE_IPS - space-delimited list of IPs which autossl should work on. unset means any."
38 echo " AUTOSSL_TLS_PORT_MAP - space-delimited list of colon-separated port number pairs denoting which port should be mapped to which one (some common ports defaulted)"
39 echo " OPENSSL_EXTRA_ARGS - additional options passed to openssl"
40 echo " STUNNEL_EXTRA_ARGS - additional options passed to stunnel"
47 elif [ "$1" = --help ]
55 if [ "$AUTOSSL_CONVENIENCE" = off
]
61 if [[ $arg =~ ^https
://([^@
/]*@
)?
([^
/ :]+) ]]
63 servername
=${BASH_REMATCH[2]}
65 if [ "${arg:0:6}" = https
: ]
67 arg
=${arg/https:/http:}
72 if [ -n "$servername" ]
74 OPENSSL_EXTRA_ARGS
="$OPENSSL_EXTRA_ARGS${OPENSSL_EXTRA_ARGS:+ }-servername $servername"
75 export OPENSSL_EXTRA_ARGS
79 if [ ! $AUTOSSL_SILENT ]
81 echo "autossl: run: ${args[@]}" >&2
83 if [ $AUTOSSL_SILENT ]
85 OPENSSL_EXTRA_ARGS
="$OPENSSL_EXTRA_ARGS${OPENSSL_EXTRA_ARGS:+ }-quiet"
88 LD_PRELOAD
=/usr
/lib
/tool
/preload
/autossl.so \
89 AUTOSSL_UPGRADE_PORTS
="80${AUTOSSL_UPGRADE_PORTS:+ }${AUTOSSL_UPGRADE_PORTS}" \
90 AUTOSSL_TLS_CMD
=autossl-conn \
91 AUTOSSL_TLS_PORT_MAP
="21:990 23:992 25:465 80:443 110:995 119:563 143:993 194:994 389:636 $AUTOSSL_TLS_PORT_MAP" \