6 s_server - SSL/TLS server program
10 B<openssl> B<s_server>
25 [B<-certform PEM|DER>]
30 [B<-dcertform PEM|DER>]
32 [B<-dkeyform PEM|DER>]
46 [B<-no_resume_ephemeral>]
50 [B<-servername_fatal>]
58 [B<-keymatexport val>]
59 [B<-keymatexportlen +int>]
62 [B<-cert_chain infile>]
63 [B<-dcert_chain infile>]
65 [B<-verifyCApath dir>]
69 [B<-verify_return_error>]
72 [B<-chainCAfile infile>]
73 [B<-verifyCAfile infile>]
78 [B<-status_timeout int>]
80 [B<-status_file infile>]
83 [B<-security_debug_verbose>]
88 [B<-max_send_frag +int>]
89 [B<-split_send_frag +int>]
90 [B<-max_pipelines +int>]
103 [B<-legacy_renegotiation>]
104 [B<-no_renegotiation>]
105 [B<-legacy_server_connect>]
106 [B<-no_resumption_on_reneg>]
107 [B<-no_legacy_server_connect>]
108 [B<-allow_no_dhe_kex>]
109 [B<-prioritize_chacha>]
112 [B<-client_sigalgs val>]
115 [B<-named_curve val>]
117 [B<-ciphersuites val>]
119 [B<-record_padding val>]
120 [B<-debug_broken_protocol>]
123 [B<-verify_name val>]
124 [B<-verify_depth int>]
127 [B<-verify_hostname val>]
128 [B<-verify_email val>]
130 [B<-ignore_critical>]
135 [B<-explicit_policy>]
144 [B<-suiteB_128_only>]
150 [B<-allow_proxy_certs>]
155 [B<-xcertform PEM|DER>]
156 [B<-xkeyform PEM|DER>]
158 [B<-psk_identity val>]
161 [B<-psk_session file>]
162 [B<-srpvfile infile>]
163 [B<-srpuserseed val>]
178 [B<-nextprotoneg val>]
182 [B<-keylogfile outfile>]
183 [B<-max_early_data int>]
190 The B<s_server> command implements a generic SSL/TLS server which listens
191 for connections on a given port using SSL/TLS.
195 In addition to the options below the B<s_server> utility also supports the
196 common and server only options documented in the
197 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
204 Print out a usage message.
208 The TCP port to listen on for connections. If not specified 4433 is used.
212 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
216 Unix domain socket to accept on.
228 For -unix, unlink any existing socket first.
230 =item B<-context val>
232 Sets the SSL context id. It can be given any string value. If this option
233 is not present a default value will be used.
235 =item B<-verify int>, B<-Verify int>
237 The verify depth to use. This specifies the maximum length of the
238 client certificate chain and makes the server request a certificate from
239 the client. With the B<-verify> option a certificate is requested but the
240 client does not have to send one, with the B<-Verify> option the client
241 must supply a certificate or an error occurs.
243 If the cipher suite cannot request a client certificate (for example an
244 anonymous cipher suite or PSK) this option has no effect.
246 =item B<-cert infile>
248 The certificate to use, most servers cipher suites require the use of a
249 certificate and some require a certificate with a certain public key type:
250 for example the DSS cipher suites require a certificate containing a DSS
251 (DSA) key. If not specified then the filename "server.pem" will be used.
255 A file containing trusted certificates to use when attempting to build the
256 client/server certificate chain related to the certificate specified via the
259 =item B<-build_chain>
261 Specify whether the application should build the certificate chain to be
262 provided to the client.
264 =item B<-nameopt val>
266 Option which determines how the subject or issuer names are displayed. The
267 B<val> argument can be a single option or multiple options separated by
268 commas. Alternatively the B<-nameopt> switch may be used more than once to
269 set multiple options. See the L<x509(1)> manual page for details.
271 =item B<-naccept +int>
273 The server will exit after receiving the specified number of connections,
276 =item B<-serverinfo val>
278 A file containing one or more blocks of PEM data. Each PEM block
279 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
280 followed by "length" bytes of extension data). If the client sends
281 an empty TLS ClientHello extension matching the type, the corresponding
282 ServerHello extension will be returned.
284 =item B<-certform PEM|DER>
286 The certificate format to use: DER or PEM. PEM is the default.
290 The private key to use. If not specified then the certificate file will
293 =item B<-keyform format>
295 The private format to use: DER or PEM. PEM is the default.
299 The private key password source. For more information about the format of B<val>
300 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
302 =item B<-dcert infile>, B<-dkey infile>
304 Specify an additional certificate and private key, these behave in the
305 same manner as the B<-cert> and B<-key> options except there is no default
306 if they are not specified (no additional certificate and key is used). As
307 noted above some cipher suites require a certificate containing a key of
308 a certain type. Some cipher suites need a certificate carrying an RSA key
309 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
310 a server can support clients which only support RSA or DSS cipher suites
311 by using an appropriate certificate.
313 =item B<-dcert_chain>
315 A file containing trusted certificates to use when attempting to build the
316 server certificate chain when a certificate specified via the B<-dcert> option
319 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
321 Additional certificate and private key format and passphrase respectively.
323 =item B<-xkey infile>, B<-xcert infile>, B<-xchain>
325 Specify an extra certificate, private key and certificate chain. These behave
326 in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
327 specified, the callback returning the first valid chain will be in use by
330 =item B<-xchain_build>
332 Specify whether the application should build the certificate chain to be
333 provided to the client for the extra certificates provided via B<-xkey infile>,
334 B<-xcert infile>, B<-xchain> options.
336 =item B<-xcertform PEM|DER>, B<-xkeyform PEM|DER>
338 Extra certificate and private key format respectively.
342 Tests non blocking I/O.
346 This option translated a line feed from the terminal into CR+LF.
350 Print extensive debugging information including a hex dump of all traffic.
354 Show all protocol messages with hex dump.
356 =item B<-msgfile outfile>
358 File to send output of B<-msg> or B<-trace> to, default standard output.
362 Prints the SSL session states.
364 =item B<-CAfile infile>
366 A file containing trusted certificates to use during client authentication
367 and to use when attempting to build the server certificate chain. The list
368 is also used in the list of acceptable client CAs passed to the client when
369 a certificate is requested.
373 The directory to use for client certificate verification. This directory
374 must be in "hash format", see L<verify(1)> for more information. These are
375 also used when building the server certificate chain.
377 =item B<-chainCApath dir>
379 The directory to use for building the chain provided to the client. This
380 directory must be in "hash format", see L<verify(1)> for more information.
382 =item B<-chainCAfile file>
384 A file containing trusted certificates to use when attempting to build the
385 server certificate chain.
389 Do not load the trusted CA certificates from the default file location.
393 Do not load the trusted CA certificates from the default directory location.
397 If this option is set then no certificate is used. This restricts the
398 cipher suites available to the anonymous ones (currently just anonymous
403 Inhibit printing of session and certificate information.
407 Sends a status message back to the client when it connects. This includes
408 information about the ciphers used and various session parameters.
409 The output is in HTML format so this option will normally be used with a
410 web browser. Cannot be used in conjunction with B<-early_data>.
414 Emulates a simple web server. Pages will be resolved relative to the
415 current directory, for example if the URL https://myhost/page.html is
416 requested the file ./page.html will be loaded. Cannot be used in conjunction
419 =item B<-tlsextdebug>
421 Print a hex dump of any TLS extensions received from the server.
425 Emulates a simple web server. Pages will be resolved relative to the
426 current directory, for example if the URL https://myhost/page.html is
427 requested the file ./page.html will be loaded. The files loaded are
428 assumed to contain a complete and correct HTTP response (lines that
429 are part of the HTTP response line and headers must end with CRLF). Cannot be
430 used in conjunction with B<-early_data>.
432 =item B<-id_prefix val>
434 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
435 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
436 servers, when each of which might be generating a unique range of session
437 IDs (eg. with a certain prefix).
439 =item B<-rand file...>
441 A file or files containing random data used to seed the random number
443 Multiple files can be specified separated by an OS-dependent character.
444 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
447 =item [B<-writerand file>]
449 Writes random data to the specified I<file> upon exit.
450 This can be used with a subsequent B<-rand> flag.
452 =item B<-verify_return_error>
454 Verification errors normally just print a message but allow the
455 connection to continue, for debugging purposes.
456 If this option is used, then verification errors close the connection.
460 Enables certificate status request support (aka OCSP stapling).
462 =item B<-status_verbose>
464 Enables certificate status request support (aka OCSP stapling) and gives
465 a verbose printout of the OCSP response.
467 =item B<-status_timeout int>
469 Sets the timeout for OCSP response to B<int> seconds.
471 =item B<-status_url val>
473 Sets a fallback responder URL to use if no responder URL is present in the
474 server certificate. Without this option an error is returned if the server
475 certificate does not contain a responder address.
477 =item B<-status_file infile>
479 Overrides any OCSP responder URLs from the certificate and always provides the
480 OCSP Response stored in the file. The file must be in DER format.
484 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
485 with B<enable-ssl-trace> for this option to work.
489 Provide a brief summary of connection parameters instead of the normal verbose
494 Simple test server which just reverses the text received from the client
495 and sends it back to the server. Also sets B<-brief>. Cannot be used in
496 conjunction with B<-early_data>.
500 Switch on asynchronous mode. Cryptographic operations will be performed
501 asynchronously. This will only have an effect if an asynchronous capable engine
502 is also used via the B<-engine> option. For test purposes the dummy async engine
503 (dasync) can be used (if available).
505 =item B<-max_send_frag +int>
507 The maximum size of data fragment to send.
508 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
510 =item B<-split_send_frag +int>
512 The size used to split data for encrypt pipelines. If more data is written in
513 one go than this value then it will be split into multiple pipelines, up to the
514 maximum number of pipelines defined by max_pipelines. This only has an effect if
515 a suitable cipher suite has been negotiated, an engine that supports pipelining
516 has been loaded, and max_pipelines is greater than 1. See
517 L<SSL_CTX_set_split_send_fragment(3)> for further information.
519 =item B<-max_pipelines +int>
521 The maximum number of encrypt/decrypt pipelines to be used. This will only have
522 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
523 engine) and a suitable cipher suite has been negotiated. The default value is 1.
524 See L<SSL_CTX_set_max_pipelines(3)> for further information.
526 =item B<-read_buf +int>
528 The default read buffer size to be used for connections. This will only have an
529 effect if the buffer size is larger than the size that would otherwise be used
530 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
531 further information).
533 =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>
535 These options require or disable the use of the specified SSL or TLS protocols.
536 By default B<s_server> will negotiate the highest mutually supported protocol
538 When a specific TLS version is required, only that version will be accepted
540 Note that not all protocols and flags may be available, depending on how
545 There are several known bug in SSL and TLS implementations. Adding this
546 option enables various workarounds.
550 Disable negotiation of TLS compression.
551 TLS compression is not recommended and is off by default as of
556 Enable negotiation of TLS compression.
557 This option was introduced in OpenSSL 1.1.0.
558 TLS compression is not recommended and is off by default as of
563 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
564 is negotiated. See B<-num_tickets>.
566 =item B<-num_tickets>
568 Control the number of tickets that will be sent to the client after a full
569 handshake in TLSv1.3. The default number of tickets is 2. This option does not
570 affect the number of tickets sent after a resumption handshake.
574 Use the server's cipher preferences, rather than the client's preferences.
576 =item B<-prioritize_chacha>
578 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
580 =item B<-no_resumption_on_reneg>
582 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
584 =item B<-client_sigalgs val>
586 Signature algorithms to support for client certificate authentication
587 (colon-separated list).
589 =item B<-named_curve val>
591 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
592 For a list of all possible curves, use:
594 $ openssl ecparam -list_curves
598 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
599 modified. This list is combined with any TLSv1.3 ciphersuites that have been
600 configured. When the client sends a list of supported ciphers the first client
601 cipher also included in the server list is used. Because the client specifies
602 the preference order, the order of the server cipherlist is irrelevant. See
603 the B<ciphers> command for more information.
605 =item B<-ciphersuites val>
607 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
608 This list is combined with any TLSv1.2 and below ciphersuites that have been
609 configured. When the client sends a list of supported ciphers the first client
610 cipher also included in the server list is used. Because the client specifies
611 the preference order, the order of the server cipherlist is irrelevant. See
612 the B<ciphers> command for more information. The format for this list is a
613 simple colon (":") separated list of TLSv1.3 ciphersuite names.
615 =item B<-dhparam infile>
617 The DH parameter file to use. The ephemeral DH cipher suites generate keys
618 using a set of DH parameters. If not specified then an attempt is made to
619 load the parameters from the server certificate file.
620 If this fails then a static set of parameters hard coded into the B<s_server>
621 program will be used.
623 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
624 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
625 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
626 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
627 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
628 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
629 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
631 Set different peer certificate verification options.
632 See the L<verify(1)> manual page for details.
634 =item B<-crl_check>, B<-crl_check_all>
636 Check the peer certificate has not been revoked by its CA.
637 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
638 option all CRLs of all CAs in the chain are checked.
642 Turns on non blocking I/O.
644 =item B<-psk_identity val>
646 Expect the client to send PSK identity B<val> when using a PSK
647 cipher suite, and warn if they do not. By default, the expected PSK
648 identity is the string "Client_identity".
650 =item B<-psk_hint val>
652 Use the PSK identity hint B<val> when using a PSK cipher suite.
656 Use the PSK key B<val> when using a PSK cipher suite. The key is
657 given as a hexadecimal number without leading 0x, for example -psk
659 This option must be provided in order to use a PSK cipher.
661 =item B<-psk_session file>
663 Use the pem encoded SSL_SESSION data stored in B<file> as the basis of a PSK.
664 Note that this will only work if TLSv1.3 is negotiated.
668 This option can only be used in conjunction with one of the DTLS options above.
669 With this option B<s_server> will listen on a UDP port for incoming connections.
670 Any ClientHellos that arrive will be checked to see if they have a cookie in
672 Any without a cookie will be responded to with a HelloVerifyRequest.
673 If a ClientHello with a cookie is received then B<s_server> will connect to
674 that peer and complete the handshake.
676 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
678 These options make B<s_server> use DTLS protocols instead of TLS.
679 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
680 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
685 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
686 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
687 available where OpenSSL has support for SCTP enabled.
689 =item B<-sctp_label_bug>
691 Use the incorrect behaviour of older OpenSSL implementations when computing
692 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
693 older broken implementations but breaks interoperability with correct
694 implementations. Must be used in conjunction with B<-sctp>. This option is only
695 available where OpenSSL has support for SCTP enabled.
699 If this option is set then no DH parameters will be loaded effectively
700 disabling the ephemeral DH cipher suites.
702 =item B<-alpn val>, B<-nextprotoneg val>
704 These flags enable the Enable the Application-Layer Protocol Negotiation
705 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
706 IETF standard and replaces NPN.
707 The B<val> list is a comma-separated list of supported protocol
708 names. The list should contain the most desirable protocols first.
709 Protocol names are printable ASCII strings, for example "http/1.1" or
711 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
715 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
716 to attempt to obtain a functional reference to the specified engine,
717 thus initialising it if needed. The engine will then be set as the default
718 for all available algorithms.
720 =item B<-keylogfile outfile>
722 Appends TLS secrets to the specified keylog file such that external programs
723 (like Wireshark) can decrypt TLS connections.
725 =item B<-max_early_data int>
727 Change the default maximum early data bytes that are specified for new sessions
728 and any incoming early data (when used in conjunction with the B<-early_data>
729 flag). The default value is approximately 16k. The argument must be an integer
730 greater than or equal to 0.
734 Accept early data where possible. Cannot be used in conjunction with B<-www>,
735 B<-WWW>, B<-HTTP> or B<-rev>.
737 =item B<-anti_replay>, B<-no_anti_replay>
739 Switches replay protection on or off, respectively. Replay protection is on by
740 default unless overridden by a configuration file. When it is on, OpenSSL will
741 automatically detect if a session ticket has been used more than once, TLSv1.3
742 has been negotiated, and early data is enabled on the server. A full handshake
743 is forced if a session ticket is used a second or subsequent time. Any early
744 data that was sent will be rejected.
748 =head1 CONNECTED COMMANDS
750 If a connection request is established with an SSL client and neither the
751 B<-www> nor the B<-WWW> option has been used then normally any data received
752 from the client is displayed and any key presses will be sent to the client.
754 Certain commands are also recognized which perform special operations. These
755 commands are a letter which must appear at the start of a line. They are listed
762 End the current SSL connection but still accept new connections.
766 End the current SSL connection and exit.
770 Renegotiate the SSL session (TLSv1.2 and below only).
774 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
779 Send some plain text down the underlying TCP connection: this should
780 cause the client to disconnect due to a protocol violation.
784 Print out some session cache status information.
788 Send a heartbeat message to the client (DTLS only)
792 Send a key update message to the client (TLSv1.3 only)
796 Send a key update message to the client and request one back (TLSv1.3 only)
800 Send a certificate request to the client (TLSv1.3 only)
806 B<s_server> can be used to debug SSL clients. To accept connections from
807 a web browser the command:
809 openssl s_server -accept 443 -www
811 can be used for example.
813 Although specifying an empty list of CAs when requesting a client certificate
814 is strictly speaking a protocol violation, some SSL clients interpret this to
815 mean any CA is acceptable. This is useful for debugging purposes.
817 The session parameters can printed out using the B<sess_id> program.
821 Because this program has a lot of options and also because some of the
822 techniques used are rather old, the C source of B<s_server> is rather hard to
823 read and not a model of how things should be done.
824 A typical SSL server program would be much simpler.
826 The output of common ciphers is wrong: it just gives the list of ciphers that
827 OpenSSL recognizes and the client supports.
829 There should be a way for the B<s_server> program to print out details of any
830 unknown cipher suites a client says it supports.
834 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
835 L<SSL_CTX_set_max_send_fragment(3)>,
836 L<SSL_CTX_set_split_send_fragment(3)>,
837 L<SSL_CTX_set_max_pipelines(3)>
841 The -no_alt_chains option was added in OpenSSL 1.1.0.
844 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
848 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
850 Licensed under the Apache License 2.0 (the "License"). You may not use
851 this file except in compliance with the License. You can obtain a copy
852 in the file LICENSE in the source distribution or at
853 L<https://www.openssl.org/source/license.html>.