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