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>]
102 [B<-legacy_renegotiation>]
103 [B<-no_renegotiation>]
104 [B<-legacy_server_connect>]
105 [B<-no_resumption_on_reneg>]
106 [B<-no_legacy_server_connect>]
107 [B<-allow_no_dhe_kex>]
108 [B<-prioritize_chacha>]
111 [B<-client_sigalgs val>]
114 [B<-named_curve val>]
116 [B<-ciphersuites val>]
118 [B<-record_padding val>]
119 [B<-debug_broken_protocol>]
122 [B<-verify_name val>]
123 [B<-verify_depth int>]
126 [B<-verify_hostname val>]
127 [B<-verify_email val>]
129 [B<-ignore_critical>]
134 [B<-explicit_policy>]
143 [B<-suiteB_128_only>]
149 [B<-allow_proxy_certs>]
154 [B<-xcertform PEM|DER>]
155 [B<-xkeyform PEM|DER>]
157 [B<-psk_identity val>]
160 [B<-psk_session file>]
161 [B<-srpvfile infile>]
162 [B<-srpuserseed val>]
176 [B<-nextprotoneg val>]
180 [B<-keylogfile outfile>]
181 [B<-max_early_data int>]
188 The B<s_server> command implements a generic SSL/TLS server which listens
189 for connections on a given port using SSL/TLS.
193 In addition to the options below the B<s_server> utility also supports the
194 common and server only options documented in the
195 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
202 Print out a usage message.
206 The TCP port to listen on for connections. If not specified 4433 is used.
210 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
214 Unix domain socket to accept on.
226 For -unix, unlink any existing socket first.
228 =item B<-context val>
230 Sets the SSL context id. It can be given any string value. If this option
231 is not present a default value will be used.
233 =item B<-verify int>, B<-Verify int>
235 The verify depth to use. This specifies the maximum length of the
236 client certificate chain and makes the server request a certificate from
237 the client. With the B<-verify> option a certificate is requested but the
238 client does not have to send one, with the B<-Verify> option the client
239 must supply a certificate or an error occurs.
241 If the cipher suite cannot request a client certificate (for example an
242 anonymous cipher suite or PSK) this option has no effect.
244 =item B<-cert infile>
246 The certificate to use, most servers cipher suites require the use of a
247 certificate and some require a certificate with a certain public key type:
248 for example the DSS cipher suites require a certificate containing a DSS
249 (DSA) key. If not specified then the filename "server.pem" will be used.
253 A file containing trusted certificates to use when attempting to build the
254 client/server certificate chain related to the certificate specified via the
257 =item B<-build_chain>
259 Specify whether the application should build the certificate chain to be
260 provided to the client.
262 =item B<-nameopt val>
264 Option which determines how the subject or issuer names are displayed. The
265 B<val> argument can be a single option or multiple options separated by
266 commas. Alternatively the B<-nameopt> switch may be used more than once to
267 set multiple options. See the L<x509(1)> manual page for details.
269 =item B<-naccept +int>
271 The server will exit after receiving the specified number of connections,
274 =item B<-serverinfo val>
276 A file containing one or more blocks of PEM data. Each PEM block
277 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
278 followed by "length" bytes of extension data). If the client sends
279 an empty TLS ClientHello extension matching the type, the corresponding
280 ServerHello extension will be returned.
282 =item B<-certform PEM|DER>
284 The certificate format to use: DER or PEM. PEM is the default.
288 The private key to use. If not specified then the certificate file will
291 =item B<-keyform format>
293 The private format to use: DER or PEM. PEM is the default.
297 The private key password source. For more information about the format of B<val>
298 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
300 =item B<-dcert infile>, B<-dkey infile>
302 Specify an additional certificate and private key, these behave in the
303 same manner as the B<-cert> and B<-key> options except there is no default
304 if they are not specified (no additional certificate and key is used). As
305 noted above some cipher suites require a certificate containing a key of
306 a certain type. Some cipher suites need a certificate carrying an RSA key
307 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
308 a server can support clients which only support RSA or DSS cipher suites
309 by using an appropriate certificate.
311 =item B<-dcert_chain>
313 A file containing trusted certificates to use when attempting to build the
314 server certificate chain when a certificate specified via the B<-dcert> option
317 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
319 Additional certificate and private key format and passphrase respectively.
321 =item B<-xkey infile>, B<-xcert infile>, B<-xchain>
323 Specify an extra certificate, private key and certificate chain. These behave
324 in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
325 specified, the callback returning the first valid chain will be in use by
328 =item B<-xchain_build>
330 Specify whether the application should build the certificate chain to be
331 provided to the client for the extra certificates provided via B<-xkey infile>,
332 B<-xcert infile>, B<-xchain> options.
334 =item B<-xcertform PEM|DER>, B<-xkeyform PEM|DER>
336 Extra certificate and private key format respectively.
340 Tests non blocking I/O.
344 This option translated a line feed from the terminal into CR+LF.
348 Print extensive debugging information including a hex dump of all traffic.
352 Show all protocol messages with hex dump.
354 =item B<-msgfile outfile>
356 File to send output of B<-msg> or B<-trace> to, default standard output.
360 Prints the SSL session states.
362 =item B<-CAfile infile>
364 A file containing trusted certificates to use during client authentication
365 and to use when attempting to build the server certificate chain. The list
366 is also used in the list of acceptable client CAs passed to the client when
367 a certificate is requested.
371 The directory to use for client certificate verification. This directory
372 must be in "hash format", see L<verify(1)> for more information. These are
373 also used when building the server certificate chain.
375 =item B<-chainCApath dir>
377 The directory to use for building the chain provided to the client. This
378 directory must be in "hash format", see L<verify(1)> for more information.
380 =item B<-chainCAfile file>
382 A file containing trusted certificates to use when attempting to build the
383 server certificate chain.
387 Do not load the trusted CA certificates from the default file location.
391 Do not load the trusted CA certificates from the default directory location.
395 If this option is set then no certificate is used. This restricts the
396 cipher suites available to the anonymous ones (currently just anonymous
401 Inhibit printing of session and certificate information.
405 Sends a status message back to the client when it connects. This includes
406 information about the ciphers used and various session parameters.
407 The output is in HTML format so this option will normally be used with a
408 web browser. Cannot be used in conjunction with B<-early_data>.
412 Emulates a simple web server. Pages will be resolved relative to the
413 current directory, for example if the URL https://myhost/page.html is
414 requested the file ./page.html will be loaded. Cannot be used in conjunction
417 =item B<-tlsextdebug>
419 Print a hex dump of any TLS extensions received from the server.
423 Emulates a simple web server. Pages will be resolved relative to the
424 current directory, for example if the URL https://myhost/page.html is
425 requested the file ./page.html will be loaded. The files loaded are
426 assumed to contain a complete and correct HTTP response (lines that
427 are part of the HTTP response line and headers must end with CRLF). Cannot be
428 used in conjunction with B<-early_data>.
430 =item B<-id_prefix val>
432 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
433 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
434 servers, when each of which might be generating a unique range of session
435 IDs (eg. with a certain prefix).
437 =item B<-rand file...>
439 A file or files containing random data used to seed the random number
441 Multiple files can be specified separated by an OS-dependent character.
442 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
445 =item [B<-writerand file>]
447 Writes random data to the specified I<file> upon exit.
448 This can be used with a subsequent B<-rand> flag.
450 =item B<-verify_return_error>
452 Verification errors normally just print a message but allow the
453 connection to continue, for debugging purposes.
454 If this option is used, then verification errors close the connection.
458 Enables certificate status request support (aka OCSP stapling).
460 =item B<-status_verbose>
462 Enables certificate status request support (aka OCSP stapling) and gives
463 a verbose printout of the OCSP response.
465 =item B<-status_timeout int>
467 Sets the timeout for OCSP response to B<int> seconds.
469 =item B<-status_url val>
471 Sets a fallback responder URL to use if no responder URL is present in the
472 server certificate. Without this option an error is returned if the server
473 certificate does not contain a responder address.
475 =item B<-status_file infile>
477 Overrides any OCSP responder URLs from the certificate and always provides the
478 OCSP Response stored in the file. The file must be in DER format.
482 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
483 with B<enable-ssl-trace> for this option to work.
487 Provide a brief summary of connection parameters instead of the normal verbose
492 Simple test server which just reverses the text received from the client
493 and sends it back to the server. Also sets B<-brief>. Cannot be used in
494 conjunction with B<-early_data>.
498 Switch on asynchronous mode. Cryptographic operations will be performed
499 asynchronously. This will only have an effect if an asynchronous capable engine
500 is also used via the B<-engine> option. For test purposes the dummy async engine
501 (dasync) can be used (if available).
503 =item B<-max_send_frag +int>
505 The maximum size of data fragment to send.
506 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
508 =item B<-split_send_frag +int>
510 The size used to split data for encrypt pipelines. If more data is written in
511 one go than this value then it will be split into multiple pipelines, up to the
512 maximum number of pipelines defined by max_pipelines. This only has an effect if
513 a suitable cipher suite has been negotiated, an engine that supports pipelining
514 has been loaded, and max_pipelines is greater than 1. See
515 L<SSL_CTX_set_split_send_fragment(3)> for further information.
517 =item B<-max_pipelines +int>
519 The maximum number of encrypt/decrypt pipelines to be used. This will only have
520 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
521 engine) and a suitable cipher suite has been negotiated. The default value is 1.
522 See L<SSL_CTX_set_max_pipelines(3)> for further information.
524 =item B<-read_buf +int>
526 The default read buffer size to be used for connections. This will only have an
527 effect if the buffer size is larger than the size that would otherwise be used
528 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
529 further information).
531 =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>
533 These options require or disable the use of the specified SSL or TLS protocols.
534 By default B<s_server> will negotiate the highest mutually supported protocol
536 When a specific TLS version is required, only that version will be accepted
538 Note that not all protocols and flags may be available, depending on how
543 There are several known bug in SSL and TLS implementations. Adding this
544 option enables various workarounds.
548 Disable negotiation of TLS compression.
549 TLS compression is not recommended and is off by default as of
554 Enable negotiation of TLS compression.
555 This option was introduced in OpenSSL 1.1.0.
556 TLS compression is not recommended and is off by default as of
561 Disable RFC4507bis session ticket support.
565 Use the server's cipher preferences, rather than the client's preferences.
567 =item B<-prioritize_chacha>
569 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
571 =item B<-no_resumption_on_reneg>
573 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
575 =item B<-client_sigalgs val>
577 Signature algorithms to support for client certificate authentication
578 (colon-separated list).
580 =item B<-named_curve val>
582 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
583 For a list of all possible curves, use:
585 $ openssl ecparam -list_curves
589 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
590 modified. This list is combined with any TLSv1.3 ciphersuites that have been
591 configured. When the client sends a list of supported ciphers the first client
592 cipher also included in the server list is used. Because the client specifies
593 the preference order, the order of the server cipherlist is irrelevant. See
594 the B<ciphers> command for more information.
596 =item B<-ciphersuites val>
598 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
599 This list is combined with any TLSv1.2 and below 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. The format for this list is a
604 simple colon (":") separated list of TLSv1.3 ciphersuite names.
606 =item B<-dhparam infile>
608 The DH parameter file to use. The ephemeral DH cipher suites generate keys
609 using a set of DH parameters. If not specified then an attempt is made to
610 load the parameters from the server certificate file.
611 If this fails then a static set of parameters hard coded into the B<s_server>
612 program will be used.
614 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
615 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
616 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
617 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
618 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
619 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
620 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
622 Set different peer certificate verification options.
623 See the L<verify(1)> manual page for details.
625 =item B<-crl_check>, B<-crl_check_all>
627 Check the peer certificate has not been revoked by its CA.
628 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
629 option all CRLs of all CAs in the chain are checked.
633 Turns on non blocking I/O.
635 =item B<-psk_identity val>
637 Expect the client to send PSK identity B<val> when using a PSK
638 cipher suite, and warn if they do not. By default, the expected PSK
639 identity is the string "Client_identity".
641 =item B<-psk_hint val>
643 Use the PSK identity hint B<val> when using a PSK cipher suite.
647 Use the PSK key B<val> when using a PSK cipher suite. The key is
648 given as a hexadecimal number without leading 0x, for example -psk
650 This option must be provided in order to use a PSK cipher.
652 =item B<-psk_session file>
654 Use the pem encoded SSL_SESSION data stored in B<file> as the basis of a PSK.
655 Note that this will only work if TLSv1.3 is negotiated.
659 This option can only be used in conjunction with one of the DTLS options above.
660 With this option B<s_server> will listen on a UDP port for incoming connections.
661 Any ClientHellos that arrive will be checked to see if they have a cookie in
663 Any without a cookie will be responded to with a HelloVerifyRequest.
664 If a ClientHello with a cookie is received then B<s_server> will connect to
665 that peer and complete the handshake.
667 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
669 These options make B<s_server> use DTLS protocols instead of TLS.
670 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
671 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
676 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
677 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
678 available where OpenSSL has support for SCTP enabled.
682 If this option is set then no DH parameters will be loaded effectively
683 disabling the ephemeral DH cipher suites.
685 =item B<-alpn val>, B<-nextprotoneg val>
687 These flags enable the Enable the Application-Layer Protocol Negotiation
688 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
689 IETF standard and replaces NPN.
690 The B<val> list is a comma-separated list of supported protocol
691 names. The list should contain the most desirable protocols first.
692 Protocol names are printable ASCII strings, for example "http/1.1" or
694 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
698 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
699 to attempt to obtain a functional reference to the specified engine,
700 thus initialising it if needed. The engine will then be set as the default
701 for all available algorithms.
703 =item B<-keylogfile outfile>
705 Appends TLS secrets to the specified keylog file such that external programs
706 (like Wireshark) can decrypt TLS connections.
708 =item B<-max_early_data int>
710 Change the default maximum early data bytes that are specified for new sessions
711 and any incoming early data (when used in conjunction with the B<-early_data>
712 flag). The default value is approximately 16k. The argument must be an integer
713 greater than or equal to 0.
717 Accept early data where possible. Cannot be used in conjunction with B<-www>,
718 B<-WWW>, B<-HTTP> or B<-rev>.
720 =item B<-anti_replay>, B<-no_anti_replay>
722 Switches replay protection on or off, respectively. Replay protection is on by
723 default unless overridden by a configuration file. When it is on, OpenSSL will
724 automatically detect if a session ticket has been used more than once, TLSv1.3
725 has been negotiated, and early data is enabled on the server. A full handshake
726 is forced if a session ticket is used a second or subsequent time. Any early
727 data that was sent will be rejected.
731 =head1 CONNECTED COMMANDS
733 If a connection request is established with an SSL client and neither the
734 B<-www> nor the B<-WWW> option has been used then normally any data received
735 from the client is displayed and any key presses will be sent to the client.
737 Certain commands are also recognized which perform special operations. These
738 commands are a letter which must appear at the start of a line. They are listed
745 End the current SSL connection but still accept new connections.
749 End the current SSL connection and exit.
753 Renegotiate the SSL session (TLSv1.2 and below only).
757 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
762 Send some plain text down the underlying TCP connection: this should
763 cause the client to disconnect due to a protocol violation.
767 Print out some session cache status information.
771 Send a heartbeat message to the client (DTLS only)
775 Send a key update message to the client (TLSv1.3 only)
779 Send a key update message to the client and request one back (TLSv1.3 only)
783 Send a certificate request to the client (TLSv1.3 only)
789 B<s_server> can be used to debug SSL clients. To accept connections from
790 a web browser the command:
792 openssl s_server -accept 443 -www
794 can be used for example.
796 Although specifying an empty list of CAs when requesting a client certificate
797 is strictly speaking a protocol violation, some SSL clients interpret this to
798 mean any CA is acceptable. This is useful for debugging purposes.
800 The session parameters can printed out using the B<sess_id> program.
804 Because this program has a lot of options and also because some of the
805 techniques used are rather old, the C source of B<s_server> is rather hard to
806 read and not a model of how things should be done.
807 A typical SSL server program would be much simpler.
809 The output of common ciphers is wrong: it just gives the list of ciphers that
810 OpenSSL recognizes and the client supports.
812 There should be a way for the B<s_server> program to print out details of any
813 unknown cipher suites a client says it supports.
817 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
818 L<SSL_CTX_set_max_send_fragment(3)>,
819 L<SSL_CTX_set_split_send_fragment(3)>,
820 L<SSL_CTX_set_max_pipelines(3)>
824 The -no_alt_chains option was first added to OpenSSL 1.1.0.
826 The -allow-no-dhe-kex and -prioritize_chacha options were first added to
831 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
833 Licensed under the OpenSSL license (the "License"). You may not use
834 this file except in compliance with the License. You can obtain a copy
835 in the file LICENSE in the source distribution or at
836 L<https://www.openssl.org/source/license.html>.