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