[ab4fdfc] | 1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
[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 |
|
---|
[8963884] | 7 | <!ENTITY stunnel-download-http "https://www.stunnel.org/downloads/archive/5.x/stunnel-&stunnel-version;.tar.gz">
|
---|
[e1e58be] | 8 | <!ENTITY stunnel-download-ftp " ">
|
---|
[ae91158] | 9 | <!ENTITY stunnel-md5sum "b16a19e2b48945ca4cc0503b761c291f">
|
---|
| 10 | <!ENTITY stunnel-size "888 KB">
|
---|
| 11 | <!ENTITY stunnel-buildsize "7.1 MB">
|
---|
[4e3dc383] | 12 | <!ENTITY stunnel-time "less than 0.1 SBU">
|
---|
[2a7d6c3e] | 13 | ]>
|
---|
| 14 |
|
---|
[436c2f7e] | 15 | <sect1 id="stunnel" xreflabel="stunnel-&stunnel-version;">
|
---|
[d3469f0] | 16 | <?dbhtml filename="stunnel.html"?>
|
---|
| 17 |
|
---|
| 18 |
|
---|
[436c2f7e] | 19 | <title>stunnel-&stunnel-version;</title>
|
---|
[d3469f0] | 20 |
|
---|
| 21 | <indexterm zone="stunnel">
|
---|
[436c2f7e] | 22 | <primary sortas="a-stunnel">stunnel</primary>
|
---|
[d3469f0] | 23 | </indexterm>
|
---|
| 24 |
|
---|
| 25 | <sect2 role="package">
|
---|
[436c2f7e] | 26 | <title>Introduction to stunnel</title>
|
---|
[d3469f0] | 27 |
|
---|
[47274444] | 28 | <para>
|
---|
| 29 | The <application>stunnel</application> package contains a program
|
---|
| 30 | that allows you to encrypt arbitrary TCP connections inside SSL (Secure
|
---|
| 31 | Sockets Layer) so you can easily communicate with clients over secure
|
---|
[6b8f495] | 32 | channels. <!--<application>stunnel</application> can be used to add SSL
|
---|
[47274444] | 33 | functionality to commonly used <application>Inetd</application> daemons
|
---|
| 34 | such as POP-2, POP-3, and IMAP servers, along with standalone daemons
|
---|
[6b8f495] | 35 | such as NNTP, SMTP, and HTTP.--> <application>stunnel</application> can
|
---|
[47274444] | 36 | also be used to tunnel PPP over network sockets without changes to the
|
---|
| 37 | server package source code.
|
---|
| 38 | </para>
|
---|
[d3469f0] | 39 |
|
---|
[4c0efc3c] | 40 | &lfs122_checked;
|
---|
[ee792ef] | 41 |
|
---|
[d3469f0] | 42 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 43 | <itemizedlist spacing="compact">
|
---|
| 44 | <listitem>
|
---|
[47274444] | 45 | <para>
|
---|
| 46 | Download (HTTP): <ulink url="&stunnel-download-http;"/>
|
---|
| 47 | </para>
|
---|
[d3469f0] | 48 | </listitem>
|
---|
| 49 | <listitem>
|
---|
[47274444] | 50 | <para>
|
---|
| 51 | Download (FTP): <ulink url="&stunnel-download-ftp;"/>
|
---|
| 52 | </para>
|
---|
[d3469f0] | 53 | </listitem>
|
---|
| 54 | <listitem>
|
---|
[47274444] | 55 | <para>
|
---|
| 56 | Download MD5 sum: &stunnel-md5sum;
|
---|
| 57 | </para>
|
---|
[d3469f0] | 58 | </listitem>
|
---|
| 59 | <listitem>
|
---|
[47274444] | 60 | <para>
|
---|
| 61 | Download size: &stunnel-size;
|
---|
| 62 | </para>
|
---|
[d3469f0] | 63 | </listitem>
|
---|
| 64 | <listitem>
|
---|
[47274444] | 65 | <para>
|
---|
| 66 | Estimated disk space required: &stunnel-buildsize;
|
---|
| 67 | </para>
|
---|
[d3469f0] | 68 | </listitem>
|
---|
| 69 | <listitem>
|
---|
[47274444] | 70 | <para>
|
---|
| 71 | Estimated build time: &stunnel-time;
|
---|
| 72 | </para>
|
---|
[d3469f0] | 73 | </listitem>
|
---|
| 74 | </itemizedlist>
|
---|
| 75 |
|
---|
[436c2f7e] | 76 | <bridgehead renderas="sect3">stunnel Dependencies</bridgehead>
|
---|
[658b42d8] | 77 |
|
---|
[372898b] | 78 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 79 | <para role="optional">
|
---|
[6b8f495] | 80 | <xref linkend="libnsl"/>,
|
---|
[17aa21c] | 81 | <ulink url="https://netcat.sourceforge.net/">netcat</ulink>
|
---|
[47274444] | 82 | (required for tests),
|
---|
[6b7a631] | 83 | <ulink url="http://ftp.porcupine.org/pub/security/index.html">tcpwrappers</ulink>,
|
---|
[47274444] | 84 | and
|
---|
[15e49d1] | 85 | <ulink url="https://dist.torproject.org/">TOR</ulink>
|
---|
[372898b] | 86 | </para>
|
---|
[d3469f0] | 87 |
|
---|
| 88 | </sect2>
|
---|
| 89 |
|
---|
| 90 | <sect2 role="installation">
|
---|
[436c2f7e] | 91 | <title>Installation of stunnel</title>
|
---|
[d3469f0] | 92 |
|
---|
[47274444] | 93 | <para>
|
---|
| 94 | The <command>stunnel</command> daemon will be run in a
|
---|
| 95 | <command>chroot</command> jail by an unprivileged user. Create the
|
---|
| 96 | new user and group using the following commands as the
|
---|
| 97 | <systemitem class="username">root</systemitem> user:
|
---|
| 98 | </para>
|
---|
[d3469f0] | 99 |
|
---|
[b785ab29] | 100 | <screen role="root"><userinput>groupadd -g 51 stunnel &&
|
---|
[436c2f7e] | 101 | useradd -c "stunnel Daemon" -d /var/lib/stunnel \
|
---|
[1ae11c9] | 102 | -g stunnel -s /bin/false -u 51 stunnel</userinput></screen>
|
---|
[d3469f0] | 103 |
|
---|
| 104 | <note>
|
---|
[47274444] | 105 | <para>
|
---|
| 106 | A signed SSL Certificate and a Private Key is necessary to run the
|
---|
| 107 | <command>stunnel</command> daemon. After the package is installed,
|
---|
| 108 | there are instructions to generate them. However, if you own or have
|
---|
| 109 | already created a signed SSL Certificate you wish to use, copy it to
|
---|
| 110 | <filename>/etc/stunnel/stunnel.pem</filename> before starting the
|
---|
| 111 | build (ensure only <systemitem class="username">root</systemitem> has
|
---|
| 112 | read and write access). The <filename class="extension">.pem</filename>
|
---|
| 113 | file must be formatted as shown below:
|
---|
| 114 | </para>
|
---|
[d3469f0] | 115 |
|
---|
[30ca77d2] | 116 | <screen><literal>-----BEGIN PRIVATE KEY-----
|
---|
| 117 | <replaceable><many encrypted lines of private key></replaceable>
|
---|
| 118 | -----END PRIVATE KEY-----
|
---|
[2a7d6c3e] | 119 | -----BEGIN CERTIFICATE-----
|
---|
[3597eb6] | 120 | <replaceable><many encrypted lines of certificate></replaceable>
|
---|
[30ca77d2] | 121 | -----END CERTIFICATE-----
|
---|
| 122 | -----BEGIN DH PARAMETERS-----
|
---|
| 123 | <replaceable><encrypted lines of dh parms></replaceable>
|
---|
| 124 | -----END DH PARAMETERS-----</literal></screen>
|
---|
[47274444] | 125 |
|
---|
[d3469f0] | 126 | </note>
|
---|
[2a7d6c3e] | 127 |
|
---|
[47274444] | 128 | <para>
|
---|
| 129 | Install <application>stunnel</application> by running the following
|
---|
| 130 | commands:
|
---|
| 131 | </para>
|
---|
[4a496c3] | 132 |
|
---|
[3c7bd00] | 133 | <screen revision="sysv"><userinput>./configure --prefix=/usr \
|
---|
[06b565e] | 134 | --sysconfdir=/etc \
|
---|
| 135 | --localstatedir=/var \
|
---|
| 136 | --disable-systemd &&
|
---|
[d3469f0] | 137 | make</userinput></screen>
|
---|
| 138 |
|
---|
[3c7bd00] | 139 | <screen revision="systemd"><userinput>./configure --prefix=/usr \
|
---|
| 140 | --sysconfdir=/etc \
|
---|
| 141 | --localstatedir=/var &&
|
---|
| 142 | make</userinput></screen>
|
---|
| 143 |
|
---|
[47274444] | 144 | <para>
|
---|
| 145 | If you have installed the optional netcat application, the
|
---|
| 146 | regression tests can be run with <command>make check</command>.
|
---|
| 147 | </para>
|
---|
[50d61ed] | 148 |
|
---|
[47274444] | 149 | <para>
|
---|
| 150 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 151 | </para>
|
---|
[305e60de] | 152 |
|
---|
[1ae11c9] | 153 | <screen role="root"><userinput>make docdir=/usr/share/doc/stunnel-&stunnel-version; install</userinput></screen>
|
---|
[305e60de] | 154 |
|
---|
[f586237] | 155 | <para revision="systemd">
|
---|
| 156 | Install the included systemd unit by running the following command as the
|
---|
| 157 | <systemitem class="username">root</systemitem> user:
|
---|
| 158 | </para>
|
---|
| 159 |
|
---|
[6a054305] | 160 | <screen role="root" revision="systemd"><userinput>install -v -m644 tools/stunnel.service /usr/lib/systemd/system</userinput></screen>
|
---|
[f586237] | 161 |
|
---|
[47274444] | 162 | <para>
|
---|
| 163 | If you do not already have a signed SSL Certificate and Private Key,
|
---|
| 164 | create the <filename>stunnel.pem</filename> file in the
|
---|
| 165 | <filename class="directory">/etc/stunnel</filename> directory using the
|
---|
| 166 | command below. You will be prompted to enter the necessary
|
---|
| 167 | information. Ensure you reply to the
|
---|
| 168 | </para>
|
---|
[4efb652] | 169 |
|
---|
[372898b] | 170 | <screen><prompt>Common Name (FQDN of your server) [localhost]:</prompt></screen>
|
---|
| 171 |
|
---|
[47274444] | 172 | <para>
|
---|
| 173 | prompt with the name or IP address you will be using
|
---|
| 174 | to access the service(s).
|
---|
| 175 | </para>
|
---|
[372898b] | 176 |
|
---|
[47274444] | 177 | <para>
|
---|
| 178 | To generate a certificate, as the
|
---|
| 179 | <systemitem class="username">root</systemitem> user, issue:
|
---|
| 180 | </para>
|
---|
[372898b] | 181 |
|
---|
| 182 | <screen role="root"><userinput>make cert</userinput></screen>
|
---|
| 183 |
|
---|
[d3469f0] | 184 | </sect2>
|
---|
[2a7d6c3e] | 185 |
|
---|
[d3469f0] | 186 | <sect2 role="commands">
|
---|
| 187 | <title>Command Explanations</title>
|
---|
[2a7d6c3e] | 188 |
|
---|
[47274444] | 189 | <para revision="sysv">
|
---|
| 190 | <parameter>--disable-systemd</parameter>: This switch disables systemd
|
---|
| 191 | socket activation support which is not available in BLFS.
|
---|
| 192 | </para>
|
---|
[06b565e] | 193 |
|
---|
[47274444] | 194 | <para>
|
---|
| 195 | <command>make docdir=... install</command>: This command installs the
|
---|
| 196 | package and changes the documentation installation directory to standard
|
---|
| 197 | naming conventions.
|
---|
| 198 | </para>
|
---|
[2a7d6c3e] | 199 |
|
---|
[d3469f0] | 200 | </sect2>
|
---|
[2a7d6c3e] | 201 |
|
---|
[d3469f0] | 202 | <sect2 role="configuration">
|
---|
[436c2f7e] | 203 | <title>Configuring stunnel</title>
|
---|
[2a7d6c3e] | 204 |
|
---|
[d3469f0] | 205 | <sect3 id="stunnel-config">
|
---|
| 206 | <title>Config Files</title>
|
---|
[2a7d6c3e] | 207 |
|
---|
[47274444] | 208 | <para>
|
---|
| 209 | <filename>/etc/stunnel/stunnel.conf</filename>
|
---|
| 210 | </para>
|
---|
[2a7d6c3e] | 211 |
|
---|
[d3469f0] | 212 | <indexterm zone="stunnel stunnel-config">
|
---|
| 213 | <primary sortas="e-etc-stunnel-stunnel.conf">/etc/stunnel/stunnel.conf</primary>
|
---|
| 214 | </indexterm>
|
---|
[2a7d6c3e] | 215 |
|
---|
[d3469f0] | 216 | </sect3>
|
---|
[2a7d6c3e] | 217 |
|
---|
[d3469f0] | 218 | <sect3>
|
---|
| 219 | <title>Configuration Information</title>
|
---|
| 220 |
|
---|
[47274444] | 221 | <para>
|
---|
| 222 | As the <systemitem class="username">root</systemitem> user,
|
---|
| 223 | create the directory used for the
|
---|
| 224 | <filename class="extension">.pid</filename> file created
|
---|
| 225 | when the <application>stunnel</application> daemon starts:
|
---|
| 226 | </para>
|
---|
[1ae11c9] | 227 |
|
---|
[8ba08b56] | 228 | <screen role="root"><userinput>install -v -m750 -o stunnel -g stunnel -d /var/lib/stunnel/run &&
|
---|
| 229 | chown stunnel:stunnel /var/lib/stunnel</userinput></screen>
|
---|
[1ae11c9] | 230 |
|
---|
[47274444] | 231 | <para>
|
---|
| 232 | Next, create a basic <filename>/etc/stunnel/stunnel.conf</filename>
|
---|
| 233 | configuration file using the following commands as the
|
---|
| 234 | <systemitem class="username">root</systemitem> user:
|
---|
| 235 | </para>
|
---|
[d3469f0] | 236 |
|
---|
[8558044] | 237 | <screen role="root"><userinput>cat > /etc/stunnel/stunnel.conf << "EOF"
|
---|
[1ae11c9] | 238 | <literal>; File: /etc/stunnel/stunnel.conf
|
---|
[2a7d6c3e] | 239 |
|
---|
[372898b] | 240 | ; Note: The pid and output locations are relative to the chroot location.
|
---|
| 241 |
|
---|
[1ae11c9] | 242 | pid = /run/stunnel.pid
|
---|
[2a7d6c3e] | 243 | chroot = /var/lib/stunnel
|
---|
| 244 | client = no
|
---|
| 245 | setuid = stunnel
|
---|
[30ca77d2] | 246 | setgid = stunnel
|
---|
[372898b] | 247 | cert = /etc/stunnel/stunnel.pem
|
---|
| 248 |
|
---|
| 249 | ;debug = 7
|
---|
| 250 | ;output = stunnel.log
|
---|
| 251 |
|
---|
| 252 | ;[https]
|
---|
| 253 | ;accept = 443
|
---|
| 254 | ;connect = 80
|
---|
| 255 | ;; "TIMEOUTclose = 0" is a workaround for a design flaw in Microsoft SSL
|
---|
| 256 | ;; Microsoft implementations do not use SSL close-notify alert and thus
|
---|
| 257 | ;; they are vulnerable to truncation attacks
|
---|
| 258 | ;TIMEOUTclose = 0</literal>
|
---|
[2a7d6c3e] | 259 |
|
---|
[bfdd32ae] | 260 | EOF</userinput></screen>
|
---|
[2a7d6c3e] | 261 |
|
---|
[47274444] | 262 | <para>
|
---|
| 263 | Finally, add the service(s) you wish to encrypt to the
|
---|
| 264 | configuration file. The format is as follows:
|
---|
| 265 | </para>
|
---|
[2a7d6c3e] | 266 |
|
---|
[3597eb6] | 267 | <screen><literal>[<replaceable><service></replaceable>]
|
---|
| 268 | accept = <replaceable><hostname:portnumber></replaceable>
|
---|
| 269 | connect = <replaceable><hostname:portnumber></replaceable></literal></screen>
|
---|
[d3469f0] | 270 |
|
---|
[6b8f495] | 271 | <!--
|
---|
[47274444] | 272 | <para>
|
---|
| 273 | If you use <application>stunnel</application> to encrypt a daemon
|
---|
| 274 | started from <command>[x]inetd</command>, you may need to disable that
|
---|
| 275 | daemon in the <filename>/etc/[x]inetd.conf</filename> file and enable a
|
---|
| 276 | corresponding <replaceable><service></replaceable>_stunnel
|
---|
| 277 | service. You may have to add an appropriate entry in
|
---|
| 278 | <filename>/etc/services</filename> as well.
|
---|
| 279 | </para>
|
---|
[6b8f495] | 280 | -->
|
---|
[d3469f0] | 281 |
|
---|
[47274444] | 282 | <para>
|
---|
| 283 | For a full explanation of the commands and syntax used in the
|
---|
| 284 | configuration file, issue <command>man stunnel</command>.
|
---|
| 285 | </para>
|
---|
[d3469f0] | 286 |
|
---|
| 287 | </sect3>
|
---|
| 288 |
|
---|
| 289 | <sect3 id="stunnel-init">
|
---|
[f586237] | 290 | <title><phrase revision="sysv">Boot Script</phrase>
|
---|
| 291 | <phrase revision="systemd">Systemd Unit</phrase></title>
|
---|
[d3469f0] | 292 |
|
---|
[47274444] | 293 | <para revision="sysv">
|
---|
| 294 | To automatically start the <command>stunnel</command> daemon when the
|
---|
| 295 | system is booted, install the
|
---|
| 296 | <filename>/etc/rc.d/init.d/stunnel</filename> bootscript from the
|
---|
| 297 | <xref linkend="bootscripts"/> package.
|
---|
| 298 | </para>
|
---|
[f586237] | 299 |
|
---|
[47274444] | 300 | <para revision="systemd">
|
---|
| 301 | To start the <command>stunnel</command>
|
---|
| 302 | daemon at boot, enable the previously installed
|
---|
| 303 | <application>systemd</application> unit by running the following
|
---|
| 304 | command as the <systemitem class="username">root</systemitem> user:
|
---|
| 305 | </para>
|
---|
[d3469f0] | 306 |
|
---|
| 307 | <indexterm zone="stunnel stunnel-init">
|
---|
| 308 | <primary sortas="f-stunnel">stunnel</primary>
|
---|
| 309 | </indexterm>
|
---|
| 310 |
|
---|
[f586237] | 311 | <screen role="root" revision="sysv"><userinput>make install-stunnel</userinput></screen>
|
---|
| 312 |
|
---|
| 313 | <screen role="root" revision="systemd"><userinput>systemctl enable stunnel</userinput></screen>
|
---|
[d3469f0] | 314 |
|
---|
| 315 | </sect3>
|
---|
| 316 |
|
---|
| 317 | </sect2>
|
---|
| 318 |
|
---|
| 319 | <sect2 role="content">
|
---|
| 320 | <title>Contents</title>
|
---|
| 321 |
|
---|
| 322 | <segmentedlist>
|
---|
| 323 | <segtitle>Installed Programs</segtitle>
|
---|
| 324 | <segtitle>Installed Library</segtitle>
|
---|
| 325 | <segtitle>Installed Directories</segtitle>
|
---|
| 326 |
|
---|
| 327 | <seglistitem>
|
---|
[49ee8357] | 328 | <seg>
|
---|
| 329 | stunnel and stunnel3
|
---|
| 330 | </seg>
|
---|
| 331 | <seg>
|
---|
| 332 | libstunnel.so
|
---|
| 333 | </seg>
|
---|
| 334 | <seg>
|
---|
[6b8f495] | 335 | /{etc,lib,var/lib}/stunnel and
|
---|
[49ee8357] | 336 | /usr/share/doc/stunnel-&stunnel-version;
|
---|
| 337 | </seg>
|
---|
[d3469f0] | 338 | </seglistitem>
|
---|
| 339 | </segmentedlist>
|
---|
| 340 |
|
---|
| 341 | <variablelist>
|
---|
| 342 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 343 | <?dbfo list-presentation="list"?>
|
---|
[869b15ae] | 344 | <?dbhtml list-presentation="table"?>
|
---|
[d3469f0] | 345 |
|
---|
| 346 | <varlistentry id="stunnel-prog">
|
---|
| 347 | <term><command>stunnel</command></term>
|
---|
| 348 | <listitem>
|
---|
[47274444] | 349 | <para>
|
---|
| 350 | is a program designed to work as an SSL
|
---|
| 351 | encryption wrapper between remote clients and local
|
---|
[6b8f495] | 352 | or remote servers
|
---|
[47274444] | 353 | </para>
|
---|
[d3469f0] | 354 | <indexterm zone="stunnel stunnel-prog">
|
---|
| 355 | <primary sortas="b-stunnel">stunnel</primary>
|
---|
| 356 | </indexterm>
|
---|
| 357 | </listitem>
|
---|
| 358 | </varlistentry>
|
---|
| 359 |
|
---|
| 360 | <varlistentry id="stunnel3">
|
---|
| 361 | <term><command>stunnel3</command></term>
|
---|
| 362 | <listitem>
|
---|
[47274444] | 363 | <para>
|
---|
| 364 | is a <application>Perl</application> wrapper script to use
|
---|
| 365 | <command>stunnel</command> 3.x syntax with
|
---|
[4c24eb0a] | 366 | <command>stunnel</command> 4.05 or later
|
---|
[47274444] | 367 | </para>
|
---|
[d3469f0] | 368 | <indexterm zone="stunnel stunnel3">
|
---|
| 369 | <primary sortas="b-stunnel3">stunnel3</primary>
|
---|
| 370 | </indexterm>
|
---|
| 371 | </listitem>
|
---|
| 372 | </varlistentry>
|
---|
| 373 |
|
---|
| 374 | <varlistentry id="libstunnel">
|
---|
[4c24eb0a] | 375 | <term><filename class="libraryfile">libstunnel.so</filename></term>
|
---|
[d3469f0] | 376 | <listitem>
|
---|
[47274444] | 377 | <para>
|
---|
| 378 | contains the API functions required by
|
---|
[4c24eb0a] | 379 | <application>stunnel</application>
|
---|
[47274444] | 380 | </para>
|
---|
[d3469f0] | 381 | <indexterm zone="stunnel libstunnel">
|
---|
| 382 | <primary sortas="c-libstunnel">libstunnel.so</primary>
|
---|
| 383 | </indexterm>
|
---|
| 384 | </listitem>
|
---|
| 385 | </varlistentry>
|
---|
| 386 |
|
---|
| 387 | </variablelist>
|
---|
| 388 |
|
---|
| 389 | </sect2>
|
---|
[2a7d6c3e] | 390 |
|
---|
| 391 | </sect1>
|
---|