Implement Maximum Fragment Length TLS extension.
[openssl.git] / doc / man1 / s_server.pod
1 =pod
2
3 =head1 NAME
4
5 openssl-s_server,
6 s_server - SSL/TLS server program
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<s_server>
11 [B<-help>]
12 [B<-port +int>]
13 [B<-accept val>]
14 [B<-unix val>]
15 [B<-4>]
16 [B<-6>]
17 [B<-unlink>]
18 [B<-context val>]
19 [B<-verify int>]
20 [B<-Verify int>]
21 [B<-cert infile>]
22 [B<-nameopt val>]
23 [B<-naccept +int>]
24 [B<-serverinfo val>]
25 [B<-certform PEM|DER>]
26 [B<-key infile>]
27 [B<-keyform format>]
28 [B<-pass val>]
29 [B<-dcert infile>]
30 [B<-dcertform PEM|DER>]
31 [B<-dkey infile>]
32 [B<-dkeyform PEM|DER>]
33 [B<-dpass val>]
34 [B<-nbio_test>]
35 [B<-crlf>]
36 [B<-debug>]
37 [B<-msg>]
38 [B<-msgfile outfile>]
39 [B<-state>]
40 [B<-CAfile infile>]
41 [B<-CApath dir>]
42 [B<-no-CAfile>]
43 [B<-no-CApath>]
44 [B<-nocert>]
45 [B<-quiet>]
46 [B<-no_resume_ephemeral>]
47 [B<-www>]
48 [B<-WWW>]
49 [B<-servername>]
50 [B<-servername_fatal>]
51 [B<-cert2 infile>]
52 [B<-key2 infile>]
53 [B<-tlsextdebug>]
54 [B<-HTTP>]
55 [B<-id_prefix val>]
56 [B<-rand file...>]
57 [B<-writerand file>]
58 [B<-keymatexport val>]
59 [B<-keymatexportlen +int>]
60 [B<-CRL infile>]
61 [B<-crl_download>]
62 [B<-cert_chain infile>]
63 [B<-dcert_chain infile>]
64 [B<-chainCApath dir>]
65 [B<-verifyCApath dir>]
66 [B<-no_cache>]
67 [B<-ext_cache>]
68 [B<-CRLform PEM|DER>]
69 [B<-verify_return_error>]
70 [B<-verify_quiet>]
71 [B<-build_chain>]
72 [B<-chainCAfile infile>]
73 [B<-verifyCAfile infile>]
74 [B<-ign_eof>]
75 [B<-no_ign_eof>]
76 [B<-status>]
77 [B<-status_verbose>]
78 [B<-status_timeout int>]
79 [B<-status_url val>]
80 [B<-status_file infile>]
81 [B<-trace>]
82 [B<-security_debug>]
83 [B<-security_debug_verbose>]
84 [B<-brief>]
85 [B<-rev>]
86 [B<-async>]
87 [B<-ssl_config val>]
88 [B<-max_send_frag +int>]
89 [B<-split_send_frag +int>]
90 [B<-max_pipelines +int>]
91 [B<-read_buf +int>]
92 [B<-no_ssl3>]
93 [B<-no_tls1>]
94 [B<-no_tls1_1>]
95 [B<-no_tls1_2>]
96 [B<-no_tls1_3>]
97 [B<-bugs>]
98 [B<-no_comp>]
99 [B<-comp>]
100 [B<-no_ticket>]
101 [B<-serverpref>]
102 [B<-legacy_renegotiation>]
103 [B<-no_renegotiation>]
104 [B<-legacy_server_connect>]
105 [B<-no_resumption_on_reneg>]
106 [B<-no_legacy_server_connect>]
107 [B<-allow_no_dhe_kex>]
108 [B<-strict>]
109 [B<-sigalgs val>]
110 [B<-client_sigalgs val>]
111 [B<-groups val>]
112 [B<-curves val>]
113 [B<-named_curve val>]
114 [B<-cipher val>]
115 [B<-dhparam infile>]
116 [B<-record_padding val>]
117 [B<-debug_broken_protocol>]
118 [B<-policy val>]
119 [B<-purpose val>]
120 [B<-verify_name val>]
121 [B<-verify_depth int>]
122 [B<-auth_level int>]
123 [B<-attime intmax>]
124 [B<-verify_hostname val>]
125 [B<-verify_email val>]
126 [B<-verify_ip>]
127 [B<-ignore_critical>]
128 [B<-issuer_checks>]
129 [B<-crl_check>]
130 [B<-crl_check_all>]
131 [B<-policy_check>]
132 [B<-explicit_policy>]
133 [B<-inhibit_any>]
134 [B<-inhibit_map>]
135 [B<-x509_strict>]
136 [B<-extended_crl>]
137 [B<-use_deltas>]
138 [B<-policy_print>]
139 [B<-check_ss_sig>]
140 [B<-trusted_first>]
141 [B<-suiteB_128_only>]
142 [B<-suiteB_128>]
143 [B<-suiteB_192>]
144 [B<-partial_chain>]
145 [B<-no_alt_chains>]
146 [B<-no_check_time>]
147 [B<-allow_proxy_certs>]
148 [B<-xkey>]
149 [B<-xcert>]
150 [B<-xchain>]
151 [B<-xchain_build>]
152 [B<-xcertform PEM|DER>]
153 [B<-xkeyform PEM|DER>]
154 [B<-nbio>]
155 [B<-psk_identity val>]
156 [B<-psk_hint val>]
157 [B<-psk val>]
158 [B<-srpvfile infile>]
159 [B<-srpuserseed val>]
160 [B<-ssl3>]
161 [B<-tls1>]
162 [B<-tls1_1>]
163 [B<-tls1_2>]
164 [B<-tls1_3>]
165 [B<-dtls>]
166 [B<-timeout>]
167 [B<-mtu +int>]
168 [B<-listen>]
169 [B<-dtls1>]
170 [B<-dtls1_2>]
171 [B<-sctp>]
172 [B<-no_dhe>]
173 [B<-nextprotoneg val>]
174 [B<-use_srtp val>]
175 [B<-alpn val>]
176 [B<-engine val>]
177 [B<-keylogfile outfile>]
178 [B<-max_early_data int>]
179 [B<-early_data>]
180
181 =head1 DESCRIPTION
182
183 The B<s_server> command implements a generic SSL/TLS server which listens
184 for connections on a given port using SSL/TLS.
185
186 =head1 OPTIONS
187
188 In addition to the options below the B<s_server> utility also supports the
189 common and server only options documented in the
190 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
191 manual page.
192
193 =over 4
194
195 =item B<-help>
196
197 Print out a usage message.
198
199 =item B<-port +int>
200
201 The TCP port to listen on for connections. If not specified 4433 is used.
202
203 =item B<-accept val>
204
205 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
206
207 =item B<-unix val>
208
209 Unix domain socket to accept on.
210
211 =item B<-4>
212
213 Use IPv4 only.
214
215 =item B<-6>
216
217 Use IPv6 only.
218
219 =item B<-unlink>
220
221 For -unix, unlink any existing socket first.
222
223 =item B<-context val>
224
225 Sets the SSL context id. It can be given any string value. If this option
226 is not present a default value will be used.
227
228 =item B<-verify int>, B<-Verify int>
229
230 The verify depth to use. This specifies the maximum length of the
231 client certificate chain and makes the server request a certificate from
232 the client. With the B<-verify> option a certificate is requested but the
233 client does not have to send one, with the B<-Verify> option the client
234 must supply a certificate or an error occurs.
235
236 If the cipher suite cannot request a client certificate (for example an
237 anonymous cipher suite or PSK) this option has no effect.
238
239 =item B<-cert infile>
240
241 The certificate to use, most servers cipher suites require the use of a
242 certificate and some require a certificate with a certain public key type:
243 for example the DSS cipher suites require a certificate containing a DSS
244 (DSA) key. If not specified then the filename "server.pem" will be used.
245
246 =item B<-nameopt val>
247
248 Option which determines how the subject or issuer names are displayed. The
249 B<val> argument can be a single option or multiple options separated by
250 commas.  Alternatively the B<-nameopt> switch may be used more than once to
251 set multiple options. See the L<x509(1)> manual page for details.
252
253 =item B<-naccept +int>
254
255 The server will exit after receiving the specified number of connections,
256 default unlimited.
257
258 =item B<-serverinfo val>
259
260 A file containing one or more blocks of PEM data.  Each PEM block
261 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
262 followed by "length" bytes of extension data).  If the client sends
263 an empty TLS ClientHello extension matching the type, the corresponding
264 ServerHello extension will be returned.
265
266 =item B<-certform PEM|DER>
267
268 The certificate format to use: DER or PEM. PEM is the default.
269
270 =item B<-key infile>
271
272 The private key to use. If not specified then the certificate file will
273 be used.
274
275 =item B<-keyform format>
276
277 The private format to use: DER or PEM. PEM is the default.
278
279 =item B<-pass val>
280
281 The private key password source. For more information about the format of B<val>
282 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
283
284 =item B<-dcert infile>, B<-dkey infile>
285
286 Specify an additional certificate and private key, these behave in the
287 same manner as the B<-cert> and B<-key> options except there is no default
288 if they are not specified (no additional certificate and key is used). As
289 noted above some cipher suites require a certificate containing a key of
290 a certain type. Some cipher suites need a certificate carrying an RSA key
291 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
292 a server can support clients which only support RSA or DSS cipher suites
293 by using an appropriate certificate.
294
295 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
296
297 Additional certificate and private key format and passphrase respectively.
298
299 =item B<-nbio_test>
300
301 Tests non blocking I/O.
302
303 =item B<-crlf>
304
305 This option translated a line feed from the terminal into CR+LF.
306
307 =item B<-debug>
308
309 Print extensive debugging information including a hex dump of all traffic.
310
311 =item B<-msg>
312
313 Show all protocol messages with hex dump.
314
315 =item B<-msgfile outfile>
316
317 File to send output of B<-msg> or B<-trace> to, default standard output.
318
319 =item B<-state>
320
321 Prints the SSL session states.
322
323 =item B<-CAfile infile>
324
325 A file containing trusted certificates to use during client authentication
326 and to use when attempting to build the server certificate chain. The list
327 is also used in the list of acceptable client CAs passed to the client when
328 a certificate is requested.
329
330 =item B<-CApath dir>
331
332 The directory to use for client certificate verification. This directory
333 must be in "hash format", see B<verify> for more information. These are
334 also used when building the server certificate chain.
335
336 =item B<-no-CAfile>
337
338 Do not load the trusted CA certificates from the default file location.
339
340 =item B<-no-CApath>
341
342 Do not load the trusted CA certificates from the default directory location.
343
344 =item B<-nocert>
345
346 If this option is set then no certificate is used. This restricts the
347 cipher suites available to the anonymous ones (currently just anonymous
348 DH).
349
350 =item B<-quiet>
351
352 Inhibit printing of session and certificate information.
353
354 =item B<-www>
355
356 Sends a status message back to the client when it connects. This includes
357 information about the ciphers used and various session parameters.
358 The output is in HTML format so this option will normally be used with a
359 web browser.
360
361 =item B<-WWW>
362
363 Emulates a simple web server. Pages will be resolved relative to the
364 current directory, for example if the URL https://myhost/page.html is
365 requested the file ./page.html will be loaded.
366
367 =item B<-tlsextdebug>
368
369 Print a hex dump of any TLS extensions received from the server.
370
371 =item B<-HTTP>
372
373 Emulates a simple web server. Pages will be resolved relative to the
374 current directory, for example if the URL https://myhost/page.html is
375 requested the file ./page.html will be loaded. The files loaded are
376 assumed to contain a complete and correct HTTP response (lines that
377 are part of the HTTP response line and headers must end with CRLF).
378
379 =item B<-id_prefix val>
380
381 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
382 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
383 servers, when each of which might be generating a unique range of session
384 IDs (eg. with a certain prefix).
385
386 =item B<-rand file...>
387
388 A file or files containing random data used to seed the random number
389 generator.
390 Multiple files can be specified separated by an OS-dependent character.
391 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
392 all others.
393
394 =item [B<-writerand file>]
395
396 Writes random data to the specified I<file> upon exit.
397 This can be used with a subsequent B<-rand> flag.
398
399 =item B<-verify_return_error>
400
401 Verification errors normally just print a message but allow the
402 connection to continue, for debugging purposes.
403 If this option is used, then verification errors close the connection.
404
405 =item B<-status>
406
407 Enables certificate status request support (aka OCSP stapling).
408
409 =item B<-status_verbose>
410
411 Enables certificate status request support (aka OCSP stapling) and gives
412 a verbose printout of the OCSP response.
413
414 =item B<-status_timeout int>
415
416 Sets the timeout for OCSP response to B<int> seconds.
417
418 =item B<-status_url val>
419
420 Sets a fallback responder URL to use if no responder URL is present in the
421 server certificate. Without this option an error is returned if the server
422 certificate does not contain a responder address.
423
424 =item B<-status_file infile>
425
426 Overrides any OCSP responder URLs from the certificate and always provides the
427 OCSP Response stored in the file. The file must be in DER format.
428
429 =item B<-trace>
430
431 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
432 with B<enable-ssl-trace> for this option to work.
433
434 =item B<-brief>
435
436 Provide a brief summary of connection parameters instead of the normal verbose
437 output.
438
439 =item B<-rev>
440
441 Simple test server which just reverses the text received from the client
442 and sends it back to the server. Also sets B<-brief>.
443
444 =item B<-async>
445
446 Switch on asynchronous mode. Cryptographic operations will be performed
447 asynchronously. This will only have an effect if an asynchronous capable engine
448 is also used via the B<-engine> option. For test purposes the dummy async engine
449 (dasync) can be used (if available).
450
451 =item B<-max_send_frag +int>
452
453 The maximum size of data fragment to send.
454 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
455
456 =item B<-split_send_frag +int>
457
458 The size used to split data for encrypt pipelines. If more data is written in
459 one go than this value then it will be split into multiple pipelines, up to the
460 maximum number of pipelines defined by max_pipelines. This only has an effect if
461 a suitable cipher suite has been negotiated, an engine that supports pipelining
462 has been loaded, and max_pipelines is greater than 1. See
463 L<SSL_CTX_set_split_send_fragment(3)> for further information.
464
465 =item B<-max_pipelines +int>
466
467 The maximum number of encrypt/decrypt pipelines to be used. This will only have
468 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
469 engine) and a suitable cipher suite has been negotiated. The default value is 1.
470 See L<SSL_CTX_set_max_pipelines(3)> for further information.
471
472 =item B<-read_buf +int>
473
474 The default read buffer size to be used for connections. This will only have an
475 effect if the buffer size is larger than the size that would otherwise be used
476 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
477 further information).
478
479 =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-tls1_1>, B<-tls1_2>, B<-tls1_3>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2>, B<-no_tls1_3>
480
481 These options require or disable the use of the specified SSL or TLS protocols.
482 By default B<s_server> will negotiate the highest mutually supported protocol
483 version.
484 When a specific TLS version is required, only that version will be accepted
485 from the client.
486
487 =item B<-bugs>
488
489 There are several known bug in SSL and TLS implementations. Adding this
490 option enables various workarounds.
491
492 =item B<-no_comp>
493
494 Disable negotiation of TLS compression.
495 TLS compression is not recommended and is off by default as of
496 OpenSSL 1.1.0.
497
498 =item B<-comp>
499
500 Enable negotiation of TLS compression.
501 This option was introduced in OpenSSL 1.1.0.
502 TLS compression is not recommended and is off by default as of
503 OpenSSL 1.1.0.
504
505 =item B<-no_ticket>
506
507 Disable RFC4507bis session ticket support.
508
509 =item B<-serverpref>
510
511 Use the server's cipher preferences, rather than the client's preferences.
512
513 =item B<-no_resumption_on_reneg>
514
515 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
516
517 =item B<-client_sigalgs val>
518
519 Signature algorithms to support for client certificate authentication
520 (colon-separated list).
521
522 =item B<-named_curve val>
523
524 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
525 For a list of all possible curves, use:
526
527     $ openssl ecparam -list_curves
528
529 =item B<-cipher val>
530
531 This allows the cipher list used by the server to be modified.  When
532 the client sends a list of supported ciphers the first client cipher
533 also included in the server list is used. Because the client specifies
534 the preference order, the order of the server cipherlist irrelevant. See
535 the B<ciphers> command for more information.
536
537 =item B<-dhparam infile>
538
539 The DH parameter file to use. The ephemeral DH cipher suites generate keys
540 using a set of DH parameters. If not specified then an attempt is made to
541 load the parameters from the server certificate file.
542 If this fails then a static set of parameters hard coded into the B<s_server>
543 program will be used.
544
545 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
546 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
547 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
548 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
549 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
550 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
551 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
552
553 Set different peer certificate verification options.
554 See the L<verify(1)> manual page for details.
555
556 =item B<-crl_check>, B<-crl_check_all>
557
558 Check the peer certificate has not been revoked by its CA.
559 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
560 option all CRLs of all CAs in the chain are checked.
561
562 =item B<-nbio>
563
564 Turns on non blocking I/O.
565
566 =item B<-psk_identity val>
567
568 Expect the client to send PSK identity B<val> when using a PSK
569 cipher suite, and warn if they do not.  By default, the expected PSK
570 identity is the string "Client_identity".
571
572 =item B<-psk_hint val>
573
574 Use the PSK identity hint B<val> when using a PSK cipher suite.
575
576 =item B<-psk val>
577
578 Use the PSK key B<val> when using a PSK cipher suite. The key is
579 given as a hexadecimal number without leading 0x, for example -psk
580 1a2b3c4d.
581 This option must be provided in order to use a PSK cipher.
582
583 =item B<-listen>
584
585 This option can only be used in conjunction with one of the DTLS options above.
586 With this option B<s_server> will listen on a UDP port for incoming connections.
587 Any ClientHellos that arrive will be checked to see if they have a cookie in
588 them or not.
589 Any without a cookie will be responded to with a HelloVerifyRequest.
590 If a ClientHello with a cookie is received then B<s_server> will connect to
591 that peer and complete the handshake.
592
593 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
594
595 These options make B<s_server> use DTLS protocols instead of TLS.
596 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
597 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
598 respectively.
599
600 =item B<-sctp>
601
602 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
603 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
604 available where OpenSSL has support for SCTP enabled.
605
606 =item B<-no_dhe>
607
608 If this option is set then no DH parameters will be loaded effectively
609 disabling the ephemeral DH cipher suites.
610
611 =item B<-alpn val>, B<-nextprotoneg val>
612
613 These flags enable the Enable the Application-Layer Protocol Negotiation
614 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
615 IETF standard and replaces NPN.
616 The B<val> list is a comma-separated list of supported protocol
617 names.  The list should contain the most desirable protocols first.
618 Protocol names are printable ASCII strings, for example "http/1.1" or
619 "spdy/3".
620 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
621
622 =item B<-engine val>
623
624 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
625 to attempt to obtain a functional reference to the specified engine,
626 thus initialising it if needed. The engine will then be set as the default
627 for all available algorithms.
628
629 =item B<-keylogfile outfile>
630
631 Appends TLS secrets to the specified keylog file such that external programs
632 (like Wireshark) can decrypt TLS connections.
633
634 =item B<-max_early_data int>
635
636 Change the default maximum early data bytes that are specified for new sessions
637 and any incoming early data (when used in conjunction with the B<-early_data>
638 flag). The default value is approximately 16k. The argument must be an integer
639 greater than or equal to 0.
640
641 =item B<-early_data>
642
643 Accept early data where possible.
644
645 =back
646
647 =head1 CONNECTED COMMANDS
648
649 If a connection request is established with an SSL client and neither the
650 B<-www> nor the B<-WWW> option has been used then normally any data received
651 from the client is displayed and any key presses will be sent to the client.
652
653 Certain single letter commands are also recognized which perform special
654 operations: these are listed below.
655
656 =over 4
657
658 =item B<q>
659
660 End the current SSL connection but still accept new connections.
661
662 =item B<Q>
663
664 End the current SSL connection and exit.
665
666 =item B<r>
667
668 Renegotiate the SSL session.
669
670 =item B<R>
671
672 Renegotiate the SSL session and request a client certificate.
673
674 =item B<P>
675
676 Send some plain text down the underlying TCP connection: this should
677 cause the client to disconnect due to a protocol violation.
678
679 =item B<S>
680
681 Print out some session cache status information.
682
683 =back
684
685 =head1 NOTES
686
687 B<s_server> can be used to debug SSL clients. To accept connections from
688 a web browser the command:
689
690  openssl s_server -accept 443 -www
691
692 can be used for example.
693
694 Although specifying an empty list of CAs when requesting a client certificate
695 is strictly speaking a protocol violation, some SSL clients interpret this to
696 mean any CA is acceptable. This is useful for debugging purposes.
697
698 The session parameters can printed out using the B<sess_id> program.
699
700 =head1 BUGS
701
702 Because this program has a lot of options and also because some of the
703 techniques used are rather old, the C source of B<s_server> is rather hard to
704 read and not a model of how things should be done.
705 A typical SSL server program would be much simpler.
706
707 The output of common ciphers is wrong: it just gives the list of ciphers that
708 OpenSSL recognizes and the client supports.
709
710 There should be a way for the B<s_server> program to print out details of any
711 unknown cipher suites a client says it supports.
712
713 =head1 SEE ALSO
714
715 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
716 L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>
717 L<SSL_CTX_set_max_pipelines(3)> 
718
719 =head1 HISTORY
720
721 The -no_alt_chains options was first added to OpenSSL 1.1.0.
722
723 =head1 COPYRIGHT
724
725 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
726
727 Licensed under the OpenSSL license (the "License").  You may not use
728 this file except in compliance with the License.  You can obtain a copy
729 in the file LICENSE in the source distribution or at
730 L<https://www.openssl.org/source/license.html>.
731
732 =cut