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