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