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