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