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