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