9d37d401bd9a1a9b2d35d4462cae1008529a1a48
[openssl.git] / doc / apps / s_server.pod
1
2 =pod
3
4 =head1 NAME
5
6 s_server - SSL/TLS server program
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<s_server>
11 [B<-accept port>]
12 [B<-naccept count>]
13 [B<-context id>]
14 [B<-verify depth>]
15 [B<-Verify depth>]
16 [B<-crl_check>]
17 [B<-crl_check_all>]
18 [B<-cert filename>]
19 [B<-certform DER|PEM>]
20 [B<-key keyfile>]
21 [B<-keyform DER|PEM>]
22 [B<-pass arg>]
23 [B<-dcert filename>]
24 [B<-dcertform DER|PEM>]
25 [B<-dkey keyfile>]
26 [B<-dkeyform DER|PEM>]
27 [B<-dpass arg>]
28 [B<-dhparam filename>]
29 [B<-nbio>]
30 [B<-nbio_test>]
31 [B<-crlf>]
32 [B<-debug>]
33 [B<-msg>]
34 [B<-state>]
35 [B<-CApath directory>]
36 [B<-CAfile filename>]
37 [B<-nocert>]
38 [B<-cipher cipherlist>]
39 [B<-quiet>]
40 [B<-no_tmp_rsa>]
41 [B<-ssl2>]
42 [B<-ssl3>]
43 [B<-tls1>]
44 [B<-no_ssl2>]
45 [B<-no_ssl3>]
46 [B<-no_tls1>]
47 [B<-no_dhe>]
48 [B<-bugs>]
49 [B<-brief>]
50 [B<-hack>]
51 [B<-www>]
52 [B<-WWW>]
53 [B<-HTTP>]
54 [B<-engine id>]
55 [B<-tlsextdebug>]
56 [B<-no_ticket>]
57 [B<-id_prefix arg>]
58 [B<-rand file(s)>]
59 [B<-serverinfo file>]
60 [B<-auth>]
61 [B<-auth_require_reneg>]
62 [B<-no_resumption_on_reneg>]
63 =head1 DESCRIPTION
64
65 The B<s_server> command implements a generic SSL/TLS server which listens
66 for connections on a given port using SSL/TLS.
67
68 =head1 OPTIONS
69
70 In addition to the options below the B<s_server> utility also supports the
71 common and server only options documented in the
72 L<SSL_CONF_cmd(3)|SSL_CONF_cmd(3)/SUPPORTED COMMAND LINE COMMANDS> manual
73 page.
74
75 =over 4
76
77 =item B<-accept port>
78
79 the TCP port to listen on for connections. If not specified 4433 is used.
80
81 =item B<-naccept count>
82
83 The server will exit after receiving B<number> connections, default unlimited. 
84
85 =item B<-context id>
86
87 sets the SSL context id. It can be given any string value. If this option
88 is not present a default value will be used.
89
90 =item B<-cert certname>
91
92 The certificate to use, most servers cipher suites require the use of a
93 certificate and some require a certificate with a certain public key type:
94 for example the DSS cipher suites require a certificate containing a DSS
95 (DSA) key. If not specified then the filename "server.pem" will be used.
96
97 =item B<-certform format>
98
99 The certificate format to use: DER or PEM. PEM is the default.
100
101 =item B<-key keyfile>
102
103 The private key to use. If not specified then the certificate file will
104 be used.
105
106 =item B<-keyform format>
107
108 The private format to use: DER or PEM. PEM is the default.
109
110 =item B<-pass arg>
111
112 the private key password source. For more information about the format of B<arg>
113 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
114
115 =item B<-dcert filename>, B<-dkey keyname>
116
117 specify an additional certificate and private key, these behave in the
118 same manner as the B<-cert> and B<-key> options except there is no default
119 if they are not specified (no additional certificate and key is used). As
120 noted above some cipher suites require a certificate containing a key of
121 a certain type. Some cipher suites need a certificate carrying an RSA key
122 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
123 a server can support clients which only support RSA or DSS cipher suites
124 by using an appropriate certificate.
125
126 =item B<-dcertform format>, B<-dkeyform format>, B<-dpass arg>
127
128 additional certificate and private key format and passphrase respectively.
129
130 =item B<-nocert>
131
132 if this option is set then no certificate is used. This restricts the
133 cipher suites available to the anonymous ones (currently just anonymous
134 DH).
135
136 =item B<-dhparam filename>
137
138 the DH parameter file to use. The ephemeral DH cipher suites generate keys
139 using a set of DH parameters. If not specified then an attempt is made to
140 load the parameters from the server certificate file. If this fails then
141 a static set of parameters hard coded into the s_server program will be used.
142
143 =item B<-no_dhe>
144
145 if this option is set then no DH parameters will be loaded effectively
146 disabling the ephemeral DH cipher suites.
147
148 =item B<-no_tmp_rsa>
149
150 certain export cipher suites sometimes use a temporary RSA key, this option
151 disables temporary RSA key generation.
152
153 =item B<-verify depth>, B<-Verify depth>
154
155 The verify depth to use. This specifies the maximum length of the
156 client certificate chain and makes the server request a certificate from
157 the client. With the B<-verify> option a certificate is requested but the
158 client does not have to send one, with the B<-Verify> option the client
159 must supply a certificate or an error occurs.
160
161 =item B<-crl_check>, B<-crl_check_all>
162
163 Check the peer certificate has not been revoked by its CA.
164 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
165 option all CRLs of all CAs in the chain are checked.
166
167 =item B<-CApath directory>
168
169 The directory to use for client certificate verification. This directory
170 must be in "hash format", see B<verify> for more information. These are
171 also used when building the server certificate chain.
172
173 =item B<-CAfile file>
174
175 A file containing trusted certificates to use during client authentication
176 and to use when attempting to build the server certificate chain. The list
177 is also used in the list of acceptable client CAs passed to the client when
178 a certificate is requested.
179
180 =item B<-state>
181
182 prints out the SSL session states.
183
184 =item B<-debug>
185
186 print extensive debugging information including a hex dump of all traffic.
187
188 =item B<-msg>
189
190 show all protocol messages with hex dump.
191
192 =item B<-trace>
193
194 show verbose trace output of protocol messages. OpenSSL needs to be compiled
195 with B<enable-ssl-trace> for this option to work.
196
197 =item B<-msgfile>
198
199 file to send output of B<-msg> or B<-trace> to, default standard output.
200
201 =item B<-nbio_test>
202
203 tests non blocking I/O
204
205 =item B<-nbio>
206
207 turns on non blocking I/O
208
209 =item B<-crlf>
210
211 this option translated a line feed from the terminal into CR+LF.
212
213 =item B<-quiet>
214
215 inhibit printing of session and certificate information.
216
217 =item B<-psk_hint hint>
218
219 Use the PSK identity hint B<hint> when using a PSK cipher suite.
220
221 =item B<-psk key>
222
223 Use the PSK key B<key> when using a PSK cipher suite. The key is
224 given as a hexadecimal number without leading 0x, for example -psk
225 1a2b3c4d.
226
227 =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
228
229 these options disable the use of certain SSL or TLS protocols. By default
230 the initial handshake uses a method which should be compatible with all
231 servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
232
233 =item B<-bugs>
234
235 there are several known bug in SSL and TLS implementations. Adding this
236 option enables various workarounds.
237
238 =item B<-brief>
239
240 only provide a brief summary of connection parameters instead of the
241 normal verbose output.
242
243 =item B<-hack>
244
245 this option enables a further workaround for some some early Netscape
246 SSL code (?).
247
248 =item B<-cipher cipherlist>
249
250 this allows the cipher list used by the server to be modified.  When
251 the client sends a list of supported ciphers the first client cipher
252 also included in the server list is used. Because the client specifies
253 the preference order, the order of the server cipherlist irrelevant. See
254 the B<ciphers> command for more information.
255
256 =item B<-tlsextdebug>
257
258 print out a hex dump of any TLS extensions received from the server.
259
260 =item B<-no_ticket>
261
262 disable RFC4507bis session ticket support. 
263
264 =item B<-www>
265
266 sends a status message back to the client when it connects. This includes
267 lots of information about the ciphers used and various session parameters.
268 The output is in HTML format so this option will normally be used with a
269 web browser.
270
271 =item B<-WWW>
272
273 emulates a simple web server. Pages will be resolved relative to the
274 current directory, for example if the URL https://myhost/page.html is
275 requested the file ./page.html will be loaded.
276
277 =item B<-HTTP>
278
279 emulates a simple web server. Pages will be resolved relative to the
280 current directory, for example if the URL https://myhost/page.html is
281 requested the file ./page.html will be loaded. The files loaded are
282 assumed to contain a complete and correct HTTP response (lines that
283 are part of the HTTP response line and headers must end with CRLF).
284
285 =item B<-rev>
286
287 simple test server which just reverses the text received from the client
288 and sends it back to the server. Also sets B<-brief>.
289
290 =item B<-engine id>
291
292 specifying an engine (by its unique B<id> string) will cause B<s_server>
293 to attempt to obtain a functional reference to the specified engine,
294 thus initialising it if needed. The engine will then be set as the default
295 for all available algorithms.
296
297 =item B<-id_prefix arg>
298
299 generate SSL/TLS session IDs prefixed by B<arg>. This is mostly useful
300 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
301 servers, when each of which might be generating a unique range of session
302 IDs (eg. with a certain prefix).
303
304 =item B<-rand file(s)>
305
306 a file or files containing random data used to seed the random number
307 generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
308 Multiple files can be specified separated by a OS-dependent character.
309 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
310 all others.
311
312 =item B<-serverinfo file>
313
314 a file containing one or more blocks of PEM data.  Each PEM block
315 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
316 followed by "length" bytes of extension data).  If the client sends
317 an empty TLS ClientHello extension matching the type, the corresponding
318 ServerHello extension will be returned.
319
320 =item B<-auth>
321
322 send RFC 5878 client and server authorization extensions in the Client Hello as well as
323 supplemental data if the server also sent the authorization extensions in the Server Hello.
324
325 =item B<-auth_require_reneg>
326
327 only send RFC 5878 client and server authorization extensions during renegotiation.
328
329 =item B<-no_resumption_on_reneg>
330
331 set SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION flag.  Required in order to receive supplemental data
332 during renegotiation if auth and auth_require_reneg are set.
333
334 =back
335
336 =head1 CONNECTED COMMANDS
337
338 If a connection request is established with an SSL client and neither the
339 B<-www> nor the B<-WWW> option has been used then normally any data received
340 from the client is displayed and any key presses will be sent to the client. 
341
342 Certain single letter commands are also recognized which perform special
343 operations: these are listed below.
344
345 =over 4
346
347 =item B<q>
348
349 end the current SSL connection but still accept new connections.
350
351 =item B<Q>
352
353 end the current SSL connection and exit.
354
355 =item B<r>
356
357 renegotiate the SSL session.
358
359 =item B<R>
360
361 renegotiate the SSL session and request a client certificate.
362
363 =item B<P>
364
365 send some plain text down the underlying TCP connection: this should
366 cause the client to disconnect due to a protocol violation.
367
368 =item B<S>
369
370 print out some session cache status information.
371
372 =back
373
374 =head1 NOTES
375
376 B<s_server> can be used to debug SSL clients. To accept connections from
377 a web browser the command:
378
379  openssl s_server -accept 443 -www
380
381 can be used for example.
382
383 Most web browsers (in particular Netscape and MSIE) only support RSA cipher
384 suites, so they cannot connect to servers which don't use a certificate
385 carrying an RSA key or a version of OpenSSL with RSA disabled.
386
387 Although specifying an empty list of CAs when requesting a client certificate
388 is strictly speaking a protocol violation, some SSL clients interpret this to
389 mean any CA is acceptable. This is useful for debugging purposes.
390
391 The session parameters can printed out using the B<sess_id> program.
392
393 =head1 BUGS
394
395 Because this program has a lot of options and also because some of
396 the techniques used are rather old, the C source of s_server is rather
397 hard to read and not a model of how things should be done. A typical
398 SSL server program would be much simpler.
399
400 The output of common ciphers is wrong: it just gives the list of ciphers that
401 OpenSSL recognizes and the client supports.
402
403 There should be a way for the B<s_server> program to print out details of any
404 unknown cipher suites a client says it supports.
405
406 =head1 SEE ALSO
407
408 L<sess_id(1)|sess_id(1)>, L<s_client(1)|s_client(1)>, L<ciphers(1)|ciphers(1)>
409
410 =cut