[2a7d6c3e] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
[6732c094] | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
[2a7d6c3e] | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
[35b2e21] | 7 | <!ENTITY stunnel-download-http "https://www.stunnel.org/downloads/stunnel-&stunnel-version;.tar.gz">
|
---|
[6c70af9b] | 8 | <!ENTITY stunnel-download-ftp "ftp://ftp.stunnel.org/stunnel/stunnel-&stunnel-version;.tar.gz">
|
---|
[4c955db] | 9 | <!ENTITY stunnel-md5sum "3a79787bdc898507224976606803d92a">
|
---|
| 10 | <!ENTITY stunnel-size "600 KB">
|
---|
| 11 | <!ENTITY stunnel-buildsize "7.1 MB">
|
---|
[0bc13d1] | 12 | <!ENTITY stunnel-time "0.1 SBU">
|
---|
[2a7d6c3e] | 13 | ]>
|
---|
| 14 |
|
---|
[436c2f7e] | 15 | <sect1 id="stunnel" xreflabel="stunnel-&stunnel-version;">
|
---|
[d3469f0] | 16 | <?dbhtml filename="stunnel.html"?>
|
---|
| 17 |
|
---|
| 18 | <sect1info>
|
---|
| 19 | <othername>$LastChangedBy$</othername>
|
---|
| 20 | <date>$Date$</date>
|
---|
| 21 | </sect1info>
|
---|
| 22 |
|
---|
[436c2f7e] | 23 | <title>stunnel-&stunnel-version;</title>
|
---|
[d3469f0] | 24 |
|
---|
| 25 | <indexterm zone="stunnel">
|
---|
[436c2f7e] | 26 | <primary sortas="a-stunnel">stunnel</primary>
|
---|
[d3469f0] | 27 | </indexterm>
|
---|
| 28 |
|
---|
| 29 | <sect2 role="package">
|
---|
[436c2f7e] | 30 | <title>Introduction to stunnel</title>
|
---|
[d3469f0] | 31 |
|
---|
[436c2f7e] | 32 | <para>The <application>stunnel</application> package contains a program
|
---|
[d3469f0] | 33 | that allows you to encrypt arbitrary TCP connections inside SSL (Secure
|
---|
| 34 | Sockets Layer) so you can easily communicate with clients over secure
|
---|
[436c2f7e] | 35 | channels. <application>stunnel</application> can be used to add SSL
|
---|
[d3469f0] | 36 | functionality to commonly used <application>Inetd</application> daemons
|
---|
[4efb652] | 37 | such as POP-2, POP-3, and IMAP servers, along with standalone daemons such
|
---|
| 38 | as NNTP, SMTP, and HTTP. <application>stunnel</application> can also be
|
---|
| 39 | used to tunnel PPP over network sockets without changes to the server
|
---|
| 40 | package source code.</para>
|
---|
[d3469f0] | 41 |
|
---|
[56d38b8] | 42 | &lfs77_checked;
|
---|
[ee792ef] | 43 |
|
---|
[d3469f0] | 44 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 45 | <itemizedlist spacing="compact">
|
---|
| 46 | <listitem>
|
---|
| 47 | <para>Download (HTTP): <ulink url="&stunnel-download-http;"/></para>
|
---|
| 48 | </listitem>
|
---|
| 49 | <listitem>
|
---|
| 50 | <para>Download (FTP): <ulink url="&stunnel-download-ftp;"/></para>
|
---|
| 51 | </listitem>
|
---|
| 52 | <listitem>
|
---|
| 53 | <para>Download MD5 sum: &stunnel-md5sum;</para>
|
---|
| 54 | </listitem>
|
---|
| 55 | <listitem>
|
---|
| 56 | <para>Download size: &stunnel-size;</para>
|
---|
| 57 | </listitem>
|
---|
| 58 | <listitem>
|
---|
| 59 | <para>Estimated disk space required: &stunnel-buildsize;</para>
|
---|
| 60 | </listitem>
|
---|
| 61 | <listitem>
|
---|
| 62 | <para>Estimated build time: &stunnel-time;</para>
|
---|
| 63 | </listitem>
|
---|
| 64 | </itemizedlist>
|
---|
| 65 |
|
---|
[436c2f7e] | 66 | <bridgehead renderas="sect3">stunnel Dependencies</bridgehead>
|
---|
[d3469f0] | 67 |
|
---|
| 68 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
[372898b] | 69 | <para role="required">
|
---|
| 70 | <xref linkend="openssl"/>
|
---|
| 71 | </para>
|
---|
| 72 |
|
---|
| 73 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 74 | <para role="optional">
|
---|
[15e49d1] | 75 | <ulink url="ftp://ftp.porcupine.org/pub/security/">tcpwrappers</ulink> and
|
---|
| 76 | <ulink url="https://dist.torproject.org/">TOR</ulink>
|
---|
[372898b] | 77 | </para>
|
---|
[d3469f0] | 78 |
|
---|
[3597eb6] | 79 | <para condition="html" role="usernotes">User Notes:
|
---|
| 80 | <ulink url="&blfs-wiki;/stunnel"/></para>
|
---|
| 81 |
|
---|
[d3469f0] | 82 | </sect2>
|
---|
| 83 |
|
---|
| 84 | <sect2 role="installation">
|
---|
[436c2f7e] | 85 | <title>Installation of stunnel</title>
|
---|
[d3469f0] | 86 |
|
---|
| 87 | <para>The <command>stunnel</command> daemon will be run in a
|
---|
| 88 | <command>chroot</command> jail by an unprivileged user. Create the
|
---|
[1ae11c9] | 89 | new user and group using the following commands as the
|
---|
[50d61ed] | 90 | <systemitem class="username">root</systemitem> user:</para>
|
---|
[d3469f0] | 91 |
|
---|
[b785ab29] | 92 | <screen role="root"><userinput>groupadd -g 51 stunnel &&
|
---|
[436c2f7e] | 93 | useradd -c "stunnel Daemon" -d /var/lib/stunnel \
|
---|
[1ae11c9] | 94 | -g stunnel -s /bin/false -u 51 stunnel</userinput></screen>
|
---|
[d3469f0] | 95 |
|
---|
| 96 | <note>
|
---|
[372898b] | 97 | <para>A signed SSL Certificate and a Private Key is necessary to run the
|
---|
[4efb652] | 98 | <command>stunnel</command> daemon. After the package is installed, there
|
---|
| 99 | are instructions to generate them. However, if you own or have already
|
---|
| 100 | created a signed SSL Certificate you wish to use, copy it to
|
---|
[50d61ed] | 101 | <filename>/etc/stunnel/stunnel.pem</filename> before starting the build
|
---|
[8ba08b56] | 102 | (ensure only <systemitem class="username">root</systemitem> has read and
|
---|
[372898b] | 103 | write access). The <filename class="extension">.pem</filename> file must
|
---|
| 104 | be formatted as shown below:</para>
|
---|
[d3469f0] | 105 |
|
---|
[30ca77d2] | 106 | <screen><literal>-----BEGIN PRIVATE KEY-----
|
---|
| 107 | <replaceable><many encrypted lines of private key></replaceable>
|
---|
| 108 | -----END PRIVATE KEY-----
|
---|
[2a7d6c3e] | 109 | -----BEGIN CERTIFICATE-----
|
---|
[3597eb6] | 110 | <replaceable><many encrypted lines of certificate></replaceable>
|
---|
[30ca77d2] | 111 | -----END CERTIFICATE-----
|
---|
| 112 | -----BEGIN DH PARAMETERS-----
|
---|
| 113 | <replaceable><encrypted lines of dh parms></replaceable>
|
---|
| 114 | -----END DH PARAMETERS-----</literal></screen>
|
---|
[d3469f0] | 115 | </note>
|
---|
[2a7d6c3e] | 116 |
|
---|
[4a496c3] | 117 | <para>Install <application>stunnel</application> by running the following
|
---|
| 118 | commands:</para>
|
---|
| 119 |
|
---|
[4efb652] | 120 | <note>
|
---|
| 121 | <para>For some systems with <application>binutils</application>
|
---|
| 122 | versions prior to 2.25, <command>configure</command> may fail. If
|
---|
| 123 | necessary, fix it either with:</para>
|
---|
[4d5c31d] | 124 |
|
---|
| 125 | <screen><userinput>sed -i '/LDFLAGS.*static_flag/ s/^/#/' configure</userinput></screen>
|
---|
| 126 |
|
---|
[4efb652] | 127 | <para>or, if <xref linkend="llvm"/> with Clang is installed, you can
|
---|
| 128 | replace <command>./configure ...</command> with <command>CC=clang
|
---|
| 129 | ./configure ...</command> in the first command below.</para>
|
---|
| 130 | </note>
|
---|
[d3469f0] | 131 |
|
---|
[06b565e] | 132 | <screen><userinput>./configure --prefix=/usr \
|
---|
| 133 | --sysconfdir=/etc \
|
---|
| 134 | --localstatedir=/var \
|
---|
| 135 | --disable-systemd &&
|
---|
[d3469f0] | 136 | make</userinput></screen>
|
---|
| 137 |
|
---|
[50d61ed] | 138 | <para>This package does not come with a test suite.</para>
|
---|
| 139 |
|
---|
[d3469f0] | 140 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
[305e60de] | 141 |
|
---|
[1ae11c9] | 142 | <screen role="root"><userinput>make docdir=/usr/share/doc/stunnel-&stunnel-version; install</userinput></screen>
|
---|
[305e60de] | 143 |
|
---|
[4efb652] | 144 | <para>If you do not already have a signed SSL Certificate and Private Key,
|
---|
| 145 | create the <filename>stunnel.pem</filename> file in the
|
---|
| 146 | <filename class="directory">/etc/stunnel</filename> directory using the
|
---|
| 147 | command below. You will be prompted to enter the necessary
|
---|
| 148 | information. Ensure you reply to the</para>
|
---|
| 149 |
|
---|
[372898b] | 150 | <screen><prompt>Common Name (FQDN of your server) [localhost]:</prompt></screen>
|
---|
| 151 |
|
---|
| 152 | <para>prompt with the name or IP address you will be using
|
---|
| 153 | to access the service(s).</para>
|
---|
| 154 |
|
---|
[4efb652] | 155 | <para>To generate a certificate, as the
|
---|
| 156 | <systemitem class="username">root</systemitem> user, issue:</para>
|
---|
[372898b] | 157 |
|
---|
| 158 | <screen role="root"><userinput>make cert</userinput></screen>
|
---|
| 159 |
|
---|
[d3469f0] | 160 | </sect2>
|
---|
[2a7d6c3e] | 161 |
|
---|
[d3469f0] | 162 | <sect2 role="commands">
|
---|
| 163 | <title>Command Explanations</title>
|
---|
[2a7d6c3e] | 164 |
|
---|
[06b565e] | 165 | <para><parameter>--disable-systemd</parameter>: This switch disables
|
---|
[4efb652] | 166 | systemd socket activation support which is not available in BLFS.</para>
|
---|
[06b565e] | 167 |
|
---|
[1ae11c9] | 168 | <para><command>make docdir=... install</command>: This command installs the
|
---|
[4efb652] | 169 | package and changes the documentation installation directory to standard
|
---|
[372898b] | 170 | naming conventions.</para>
|
---|
[2a7d6c3e] | 171 |
|
---|
[d3469f0] | 172 | </sect2>
|
---|
[2a7d6c3e] | 173 |
|
---|
[d3469f0] | 174 | <sect2 role="configuration">
|
---|
[436c2f7e] | 175 | <title>Configuring stunnel</title>
|
---|
[2a7d6c3e] | 176 |
|
---|
[d3469f0] | 177 | <sect3 id="stunnel-config">
|
---|
| 178 | <title>Config Files</title>
|
---|
[2a7d6c3e] | 179 |
|
---|
[d3469f0] | 180 | <para><filename>/etc/stunnel/stunnel.conf</filename></para>
|
---|
[2a7d6c3e] | 181 |
|
---|
[d3469f0] | 182 | <indexterm zone="stunnel stunnel-config">
|
---|
| 183 | <primary sortas="e-etc-stunnel-stunnel.conf">/etc/stunnel/stunnel.conf</primary>
|
---|
| 184 | </indexterm>
|
---|
[2a7d6c3e] | 185 |
|
---|
[d3469f0] | 186 | </sect3>
|
---|
[2a7d6c3e] | 187 |
|
---|
[d3469f0] | 188 | <sect3>
|
---|
| 189 | <title>Configuration Information</title>
|
---|
| 190 |
|
---|
[1ae11c9] | 191 | <para>As the <systemitem class="username">root</systemitem> user,
|
---|
| 192 | create the directory used for the
|
---|
[4efb652] | 193 | <filename class="extension">.pid</filename> file created
|
---|
[436c2f7e] | 194 | when the <application>stunnel</application> daemon starts:</para>
|
---|
[1ae11c9] | 195 |
|
---|
[8ba08b56] | 196 | <screen role="root"><userinput>install -v -m750 -o stunnel -g stunnel -d /var/lib/stunnel/run &&
|
---|
| 197 | chown stunnel:stunnel /var/lib/stunnel</userinput></screen>
|
---|
[1ae11c9] | 198 |
|
---|
| 199 | <para>Next, create a basic <filename>/etc/stunnel/stunnel.conf</filename>
|
---|
| 200 | configuration file using the following commands as the
|
---|
| 201 | <systemitem class="username">root</systemitem> user:</para>
|
---|
[d3469f0] | 202 |
|
---|
[708f97e9] | 203 | <screen role="root"><userinput>cat >/etc/stunnel/stunnel.conf << "EOF" &&
|
---|
[1ae11c9] | 204 | <literal>; File: /etc/stunnel/stunnel.conf
|
---|
[2a7d6c3e] | 205 |
|
---|
[372898b] | 206 | ; Note: The pid and output locations are relative to the chroot location.
|
---|
| 207 |
|
---|
[1ae11c9] | 208 | pid = /run/stunnel.pid
|
---|
[2a7d6c3e] | 209 | chroot = /var/lib/stunnel
|
---|
| 210 | client = no
|
---|
| 211 | setuid = stunnel
|
---|
[30ca77d2] | 212 | setgid = stunnel
|
---|
[372898b] | 213 | cert = /etc/stunnel/stunnel.pem
|
---|
| 214 |
|
---|
| 215 | ;debug = 7
|
---|
| 216 | ;output = stunnel.log
|
---|
| 217 |
|
---|
| 218 | ;[https]
|
---|
| 219 | ;accept = 443
|
---|
| 220 | ;connect = 80
|
---|
| 221 | ;; "TIMEOUTclose = 0" is a workaround for a design flaw in Microsoft SSL
|
---|
| 222 | ;; Microsoft implementations do not use SSL close-notify alert and thus
|
---|
| 223 | ;; they are vulnerable to truncation attacks
|
---|
| 224 | ;TIMEOUTclose = 0</literal>
|
---|
[2a7d6c3e] | 225 |
|
---|
[708f97e9] | 226 | EOF
|
---|
| 227 | chmod -v 644 /etc/stunnel/stunnel.conf</userinput></screen>
|
---|
[2a7d6c3e] | 228 |
|
---|
[4efb652] | 229 | <para>Finally, add the service(s) you wish to encrypt to the
|
---|
[1ae11c9] | 230 | configuration file. The format is as follows:</para>
|
---|
[2a7d6c3e] | 231 |
|
---|
[3597eb6] | 232 | <screen><literal>[<replaceable><service></replaceable>]
|
---|
| 233 | accept = <replaceable><hostname:portnumber></replaceable>
|
---|
| 234 | connect = <replaceable><hostname:portnumber></replaceable></literal></screen>
|
---|
[d3469f0] | 235 |
|
---|
[436c2f7e] | 236 | <para>If you use <application>stunnel</application> to encrypt a daemon
|
---|
[d3469f0] | 237 | started from <command>[x]inetd</command>, you may need to disable that
|
---|
| 238 | daemon in the <filename>/etc/[x]inetd.conf</filename> file and enable a
|
---|
[3597eb6] | 239 | corresponding <replaceable><service></replaceable>_stunnel service. You
|
---|
[d3469f0] | 240 | may have to add an appropriate entry in <filename>/etc/services</filename>
|
---|
| 241 | as well.</para>
|
---|
| 242 |
|
---|
| 243 | <para>For a full explanation of the commands and syntax used in the
|
---|
[4efb652] | 244 | configuration file, issue <command>man stunnel</command>.</para>
|
---|
[d3469f0] | 245 |
|
---|
| 246 | </sect3>
|
---|
| 247 |
|
---|
| 248 | <sect3 id="stunnel-init">
|
---|
| 249 | <title>Boot Script</title>
|
---|
| 250 |
|
---|
| 251 | <para>To automatically start the <command>stunnel</command> daemon
|
---|
[4efb652] | 252 | when the system is booted, install the
|
---|
[d3469f0] | 253 | <filename>/etc/rc.d/init.d/stunnel</filename> bootscript from the
|
---|
[5254d12] | 254 | <xref linkend="bootscripts"/> package.</para>
|
---|
[d3469f0] | 255 |
|
---|
| 256 | <indexterm zone="stunnel stunnel-init">
|
---|
| 257 | <primary sortas="f-stunnel">stunnel</primary>
|
---|
| 258 | </indexterm>
|
---|
| 259 |
|
---|
| 260 | <screen role="root"><userinput>make install-stunnel</userinput></screen>
|
---|
| 261 |
|
---|
| 262 | </sect3>
|
---|
| 263 |
|
---|
| 264 | </sect2>
|
---|
| 265 |
|
---|
| 266 | <sect2 role="content">
|
---|
| 267 | <title>Contents</title>
|
---|
| 268 |
|
---|
| 269 | <segmentedlist>
|
---|
| 270 | <segtitle>Installed Programs</segtitle>
|
---|
| 271 | <segtitle>Installed Library</segtitle>
|
---|
| 272 | <segtitle>Installed Directories</segtitle>
|
---|
| 273 |
|
---|
| 274 | <seglistitem>
|
---|
| 275 | <seg>stunnel and stunnel3</seg>
|
---|
| 276 | <seg>libstunnel.so</seg>
|
---|
[4efb652] | 277 | <seg>/etc/stunnel,
|
---|
[372898b] | 278 | /usr/lib/stunnel,
|
---|
| 279 | /usr/share/doc/stunnel-&stunnel-version;, and
|
---|
| 280 | /var/lib/stunnel</seg>
|
---|
[d3469f0] | 281 | </seglistitem>
|
---|
| 282 | </segmentedlist>
|
---|
| 283 |
|
---|
| 284 | <variablelist>
|
---|
| 285 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 286 | <?dbfo list-presentation="list"?>
|
---|
[869b15ae] | 287 | <?dbhtml list-presentation="table"?>
|
---|
[d3469f0] | 288 |
|
---|
| 289 | <varlistentry id="stunnel-prog">
|
---|
| 290 | <term><command>stunnel</command></term>
|
---|
| 291 | <listitem>
|
---|
| 292 | <para> is a program designed to work as an SSL
|
---|
| 293 | encryption wrapper between remote clients and local
|
---|
[3597eb6] | 294 | (<command>{x}inetd</command>-startable) or remote servers.</para>
|
---|
[d3469f0] | 295 | <indexterm zone="stunnel stunnel-prog">
|
---|
| 296 | <primary sortas="b-stunnel">stunnel</primary>
|
---|
| 297 | </indexterm>
|
---|
| 298 | </listitem>
|
---|
| 299 | </varlistentry>
|
---|
| 300 |
|
---|
| 301 | <varlistentry id="stunnel3">
|
---|
| 302 | <term><command>stunnel3</command></term>
|
---|
| 303 | <listitem>
|
---|
| 304 | <para>is a <application>Perl</application> wrapper script to use
|
---|
| 305 | <command>stunnel</command> 3.x syntax with <command>stunnel</command>
|
---|
| 306 | >=4.05.</para>
|
---|
| 307 | <indexterm zone="stunnel stunnel3">
|
---|
| 308 | <primary sortas="b-stunnel3">stunnel3</primary>
|
---|
| 309 | </indexterm>
|
---|
| 310 | </listitem>
|
---|
| 311 | </varlistentry>
|
---|
| 312 |
|
---|
| 313 | <varlistentry id="libstunnel">
|
---|
| 314 | <term><filename class='libraryfile'>libstunnel.so</filename></term>
|
---|
| 315 | <listitem>
|
---|
| 316 | <para> contains the API functions required by
|
---|
[436c2f7e] | 317 | <application>stunnel</application>.</para>
|
---|
[d3469f0] | 318 | <indexterm zone="stunnel libstunnel">
|
---|
| 319 | <primary sortas="c-libstunnel">libstunnel.so</primary>
|
---|
| 320 | </indexterm>
|
---|
| 321 | </listitem>
|
---|
| 322 | </varlistentry>
|
---|
| 323 |
|
---|
| 324 | </variablelist>
|
---|
| 325 |
|
---|
| 326 | </sect2>
|
---|
[2a7d6c3e] | 327 |
|
---|
| 328 | </sect1>
|
---|