source: postlfs/security/stunnel.xml

trunk
Last change on this file was 5461893, checked in by Bruce Dubbs <bdubbs@…>, 2 months ago

Tag security chapter and qemu

  • Property mode set to 100644
File size: 12.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
7 <!ENTITY stunnel-download-http "https://www.stunnel.org/downloads/archive/5.x/stunnel-&stunnel-version;.tar.gz">
8 <!ENTITY stunnel-download-ftp " ">
9 <!ENTITY stunnel-md5sum "61d35d2df1b96b23ed6fb20cf5ddb613">
10 <!ENTITY stunnel-size "880 KB">
11 <!ENTITY stunnel-buildsize "7.5 MB">
12 <!ENTITY stunnel-time "less than 0.1 SBU">
13]>
14
15<sect1 id="stunnel" xreflabel="stunnel-&stunnel-version;">
16 <?dbhtml filename="stunnel.html"?>
17
18
19 <title>stunnel-&stunnel-version;</title>
20
21 <indexterm zone="stunnel">
22 <primary sortas="a-stunnel">stunnel</primary>
23 </indexterm>
24
25 <sect2 role="package">
26 <title>Introduction to stunnel</title>
27
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
32 channels. <!--<application>stunnel</application> can be used to add SSL
33 functionality to commonly used <application>Inetd</application> daemons
34 such as POP-2, POP-3, and IMAP servers, along with standalone daemons
35 such as NNTP, SMTP, and HTTP.--> <application>stunnel</application> can
36 also be used to tunnel PPP over network sockets without changes to the
37 server package source code.
38 </para>
39
40 &lfs121_checked;
41
42 <bridgehead renderas="sect3">Package Information</bridgehead>
43 <itemizedlist spacing="compact">
44 <listitem>
45 <para>
46 Download (HTTP): <ulink url="&stunnel-download-http;"/>
47 </para>
48 </listitem>
49 <listitem>
50 <para>
51 Download (FTP): <ulink url="&stunnel-download-ftp;"/>
52 </para>
53 </listitem>
54 <listitem>
55 <para>
56 Download MD5 sum: &stunnel-md5sum;
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 Download size: &stunnel-size;
62 </para>
63 </listitem>
64 <listitem>
65 <para>
66 Estimated disk space required: &stunnel-buildsize;
67 </para>
68 </listitem>
69 <listitem>
70 <para>
71 Estimated build time: &stunnel-time;
72 </para>
73 </listitem>
74 </itemizedlist>
75
76 <bridgehead renderas="sect3">stunnel Dependencies</bridgehead>
77
78 <bridgehead renderas="sect4">Optional</bridgehead>
79 <para role="optional">
80 <xref linkend="libnsl"/>,
81 <ulink url="https://netcat.sourceforge.net/">netcat</ulink>
82 (required for tests),
83 <ulink url="http://ftp.porcupine.org/pub/security/index.html">tcpwrappers</ulink>,
84 and
85 <ulink url="https://dist.torproject.org/">TOR</ulink>
86 </para>
87
88 </sect2>
89
90 <sect2 role="installation">
91 <title>Installation of stunnel</title>
92
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>
99
100<screen role="root"><userinput>groupadd -g 51 stunnel &amp;&amp;
101useradd -c "stunnel Daemon" -d /var/lib/stunnel \
102 -g stunnel -s /bin/false -u 51 stunnel</userinput></screen>
103
104 <note>
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>
115
116<screen><literal>-----BEGIN PRIVATE KEY-----
117<replaceable>&lt;many encrypted lines of private key&gt;</replaceable>
118-----END PRIVATE KEY-----
119-----BEGIN CERTIFICATE-----
120<replaceable>&lt;many encrypted lines of certificate&gt;</replaceable>
121-----END CERTIFICATE-----
122-----BEGIN DH PARAMETERS-----
123<replaceable>&lt;encrypted lines of dh parms&gt;</replaceable>
124-----END DH PARAMETERS-----</literal></screen>
125
126 </note>
127
128 <para>
129 Install <application>stunnel</application> by running the following
130 commands:
131 </para>
132
133<screen revision="sysv"><userinput>./configure --prefix=/usr \
134 --sysconfdir=/etc \
135 --localstatedir=/var \
136 --disable-systemd &amp;&amp;
137make</userinput></screen>
138
139<screen revision="systemd"><userinput>./configure --prefix=/usr \
140 --sysconfdir=/etc \
141 --localstatedir=/var &amp;&amp;
142make</userinput></screen>
143
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>
148
149 <para>
150 Now, as the <systemitem class="username">root</systemitem> user:
151 </para>
152
153<screen role="root"><userinput>make docdir=/usr/share/doc/stunnel-&stunnel-version; install</userinput></screen>
154
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
160<screen role="root" revision="systemd"><userinput>install -v -m644 tools/stunnel.service /usr/lib/systemd/system</userinput></screen>
161
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>
169
170<screen><prompt>Common Name (FQDN of your server) [localhost]:</prompt></screen>
171
172 <para>
173 prompt with the name or IP address you will be using
174 to access the service(s).
175 </para>
176
177 <para>
178 To generate a certificate, as the
179 <systemitem class="username">root</systemitem> user, issue:
180 </para>
181
182<screen role="root"><userinput>make cert</userinput></screen>
183
184 </sect2>
185
186 <sect2 role="commands">
187 <title>Command Explanations</title>
188
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>
193
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>
199
200 </sect2>
201
202 <sect2 role="configuration">
203 <title>Configuring stunnel</title>
204
205 <sect3 id="stunnel-config">
206 <title>Config Files</title>
207
208 <para>
209 <filename>/etc/stunnel/stunnel.conf</filename>
210 </para>
211
212 <indexterm zone="stunnel stunnel-config">
213 <primary sortas="e-etc-stunnel-stunnel.conf">/etc/stunnel/stunnel.conf</primary>
214 </indexterm>
215
216 </sect3>
217
218 <sect3>
219 <title>Configuration Information</title>
220
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>
227
228<screen role="root"><userinput>install -v -m750 -o stunnel -g stunnel -d /var/lib/stunnel/run &amp;&amp;
229chown stunnel:stunnel /var/lib/stunnel</userinput></screen>
230
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>
236
237<screen role="root"><userinput>cat &gt; /etc/stunnel/stunnel.conf &lt;&lt; "EOF"
238<literal>; File: /etc/stunnel/stunnel.conf
239
240; Note: The pid and output locations are relative to the chroot location.
241
242pid = /run/stunnel.pid
243chroot = /var/lib/stunnel
244client = no
245setuid = stunnel
246setgid = stunnel
247cert = /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>
259
260EOF</userinput></screen>
261
262 <para>
263 Finally, add the service(s) you wish to encrypt to the
264 configuration file. The format is as follows:
265 </para>
266
267<screen><literal>[<replaceable>&lt;service&gt;</replaceable>]
268accept = <replaceable>&lt;hostname:portnumber&gt;</replaceable>
269connect = <replaceable>&lt;hostname:portnumber&gt;</replaceable></literal></screen>
270
271<!--
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>&lt;service&gt;</replaceable>_stunnel
277 service. You may have to add an appropriate entry in
278 <filename>/etc/services</filename> as well.
279 </para>
280-->
281
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>
286
287 </sect3>
288
289 <sect3 id="stunnel-init">
290 <title><phrase revision="sysv">Boot Script</phrase>
291 <phrase revision="systemd">Systemd Unit</phrase></title>
292
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>
299
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>
306
307 <indexterm zone="stunnel stunnel-init">
308 <primary sortas="f-stunnel">stunnel</primary>
309 </indexterm>
310
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>
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>
328 <seg>
329 stunnel and stunnel3
330 </seg>
331 <seg>
332 libstunnel.so
333 </seg>
334 <seg>
335 /{etc,lib,var/lib}/stunnel and
336 /usr/share/doc/stunnel-&stunnel-version;
337 </seg>
338 </seglistitem>
339 </segmentedlist>
340
341 <variablelist>
342 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
343 <?dbfo list-presentation="list"?>
344 <?dbhtml list-presentation="table"?>
345
346 <varlistentry id="stunnel-prog">
347 <term><command>stunnel</command></term>
348 <listitem>
349 <para>
350 is a program designed to work as an SSL
351 encryption wrapper between remote clients and local
352 or remote servers
353 </para>
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>
363 <para>
364 is a <application>Perl</application> wrapper script to use
365 <command>stunnel</command> 3.x syntax with
366 <command>stunnel</command> 4.05 or later
367 </para>
368 <indexterm zone="stunnel stunnel3">
369 <primary sortas="b-stunnel3">stunnel3</primary>
370 </indexterm>
371 </listitem>
372 </varlistentry>
373
374 <varlistentry id="libstunnel">
375 <term><filename class="libraryfile">libstunnel.so</filename></term>
376 <listitem>
377 <para>
378 contains the API functions required by
379 <application>stunnel</application>
380 </para>
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>
390
391</sect1>
Note: See TracBrowser for help on using the repository browser.