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>]
186 The B<s_server> command implements a generic SSL/TLS server which listens
187 for connections on a given port using SSL/TLS.
191 In addition to the options below the B<s_server> utility also supports the
192 common and server only options documented in the
193 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
200 Print out a usage message.
204 The TCP port to listen on for connections. If not specified 4433 is used.
208 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
212 Unix domain socket to accept on.
224 For -unix, unlink any existing socket first.
226 =item B<-context val>
228 Sets the SSL context id. It can be given any string value. If this option
229 is not present a default value will be used.
231 =item B<-verify int>, B<-Verify int>
233 The verify depth to use. This specifies the maximum length of the
234 client certificate chain and makes the server request a certificate from
235 the client. With the B<-verify> option a certificate is requested but the
236 client does not have to send one, with the B<-Verify> option the client
237 must supply a certificate or an error occurs.
239 If the cipher suite cannot request a client certificate (for example an
240 anonymous cipher suite or PSK) this option has no effect.
242 =item B<-cert infile>
244 The certificate to use, most servers cipher suites require the use of a
245 certificate and some require a certificate with a certain public key type:
246 for example the DSS cipher suites require a certificate containing a DSS
247 (DSA) key. If not specified then the filename "server.pem" will be used.
251 A file containing trusted certificates to use when attempting to build the
252 client/server certificate chain related to the certificate specified via the
255 =item B<-build_chain>
257 Specify whether the application should build the certificate chain to be
258 provided to the client.
260 =item B<-nameopt val>
262 Option which determines how the subject or issuer names are displayed. The
263 B<val> argument can be a single option or multiple options separated by
264 commas. Alternatively the B<-nameopt> switch may be used more than once to
265 set multiple options. See the L<x509(1)> manual page for details.
267 =item B<-naccept +int>
269 The server will exit after receiving the specified number of connections,
272 =item B<-serverinfo val>
274 A file containing one or more blocks of PEM data. Each PEM block
275 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
276 followed by "length" bytes of extension data). If the client sends
277 an empty TLS ClientHello extension matching the type, the corresponding
278 ServerHello extension will be returned.
280 =item B<-certform PEM|DER>
282 The certificate format to use: DER or PEM. PEM is the default.
286 The private key to use. If not specified then the certificate file will
289 =item B<-keyform format>
291 The private format to use: DER or PEM. PEM is the default.
295 The private key password source. For more information about the format of B<val>
296 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
298 =item B<-dcert infile>, B<-dkey infile>
300 Specify an additional certificate and private key, these behave in the
301 same manner as the B<-cert> and B<-key> options except there is no default
302 if they are not specified (no additional certificate and key is used). As
303 noted above some cipher suites require a certificate containing a key of
304 a certain type. Some cipher suites need a certificate carrying an RSA key
305 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
306 a server can support clients which only support RSA or DSS cipher suites
307 by using an appropriate certificate.
309 =item B<-dcert_chain>
311 A file containing trusted certificates to use when attempting to build the
312 server certificate chain when a certificate specified via the B<-dcert> option
315 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
317 Additional certificate and private key format and passphrase respectively.
319 =item B<-xkey infile>, B<-xcert infile>, B<-xchain>
321 Specify an extra certificate, private key and certificate chain. These behave
322 in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
323 specified, the callback returning the first valid chain will be in use by
326 =item B<-xchain_build>
328 Specify whether the application should build the certificate chain to be
329 provided to the client for the extra certificates provided via B<-xkey infile>,
330 B<-xcert infile>, B<-xchain> options.
332 =item B<-xcertform PEM|DER>, B<-xkeyform PEM|DER>
334 Extra certificate and private key format respectively.
338 Tests non blocking I/O.
342 This option translated a line feed from the terminal into CR+LF.
346 Print extensive debugging information including a hex dump of all traffic.
350 Show all protocol messages with hex dump.
352 =item B<-msgfile outfile>
354 File to send output of B<-msg> or B<-trace> to, default standard output.
358 Prints the SSL session states.
360 =item B<-CAfile infile>
362 A file containing trusted certificates to use during client authentication
363 and to use when attempting to build the server certificate chain. The list
364 is also used in the list of acceptable client CAs passed to the client when
365 a certificate is requested.
369 The directory to use for client certificate verification. This directory
370 must be in "hash format", see L<verify(1)> for more information. These are
371 also used when building the server certificate chain.
373 =item B<-chainCApath dir>
375 The directory to use for building the chain provided to the client. This
376 directory must be in "hash format", see L<verify(1)> for more information.
378 =item B<-chainCAfile file>
380 A file containing trusted certificates to use when attempting to build the
381 server certificate chain.
385 Do not load the trusted CA certificates from the default file location.
389 Do not load the trusted CA certificates from the default directory location.
393 If this option is set then no certificate is used. This restricts the
394 cipher suites available to the anonymous ones (currently just anonymous
399 Inhibit printing of session and certificate information.
403 Sends a status message back to the client when it connects. This includes
404 information about the ciphers used and various session parameters.
405 The output is in HTML format so this option will normally be used with a
410 Emulates a simple web server. Pages will be resolved relative to the
411 current directory, for example if the URL https://myhost/page.html is
412 requested the file ./page.html will be loaded.
414 =item B<-tlsextdebug>
416 Print a hex dump of any TLS extensions received from the server.
420 Emulates a simple web server. Pages will be resolved relative to the
421 current directory, for example if the URL https://myhost/page.html is
422 requested the file ./page.html will be loaded. The files loaded are
423 assumed to contain a complete and correct HTTP response (lines that
424 are part of the HTTP response line and headers must end with CRLF).
426 =item B<-id_prefix val>
428 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
429 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
430 servers, when each of which might be generating a unique range of session
431 IDs (eg. with a certain prefix).
433 =item B<-rand file...>
435 A file or files containing random data used to seed the random number
437 Multiple files can be specified separated by an OS-dependent character.
438 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
441 =item [B<-writerand file>]
443 Writes random data to the specified I<file> upon exit.
444 This can be used with a subsequent B<-rand> flag.
446 =item B<-verify_return_error>
448 Verification errors normally just print a message but allow the
449 connection to continue, for debugging purposes.
450 If this option is used, then verification errors close the connection.
454 Enables certificate status request support (aka OCSP stapling).
456 =item B<-status_verbose>
458 Enables certificate status request support (aka OCSP stapling) and gives
459 a verbose printout of the OCSP response.
461 =item B<-status_timeout int>
463 Sets the timeout for OCSP response to B<int> seconds.
465 =item B<-status_url val>
467 Sets a fallback responder URL to use if no responder URL is present in the
468 server certificate. Without this option an error is returned if the server
469 certificate does not contain a responder address.
471 =item B<-status_file infile>
473 Overrides any OCSP responder URLs from the certificate and always provides the
474 OCSP Response stored in the file. The file must be in DER format.
478 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
479 with B<enable-ssl-trace> for this option to work.
483 Provide a brief summary of connection parameters instead of the normal verbose
488 Simple test server which just reverses the text received from the client
489 and sends it back to the server. Also sets B<-brief>.
493 Switch on asynchronous mode. Cryptographic operations will be performed
494 asynchronously. This will only have an effect if an asynchronous capable engine
495 is also used via the B<-engine> option. For test purposes the dummy async engine
496 (dasync) can be used (if available).
498 =item B<-max_send_frag +int>
500 The maximum size of data fragment to send.
501 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
503 =item B<-split_send_frag +int>
505 The size used to split data for encrypt pipelines. If more data is written in
506 one go than this value then it will be split into multiple pipelines, up to the
507 maximum number of pipelines defined by max_pipelines. This only has an effect if
508 a suitable cipher suite has been negotiated, an engine that supports pipelining
509 has been loaded, and max_pipelines is greater than 1. See
510 L<SSL_CTX_set_split_send_fragment(3)> for further information.
512 =item B<-max_pipelines +int>
514 The maximum number of encrypt/decrypt pipelines to be used. This will only have
515 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
516 engine) and a suitable cipher suite has been negotiated. The default value is 1.
517 See L<SSL_CTX_set_max_pipelines(3)> for further information.
519 =item B<-read_buf +int>
521 The default read buffer size to be used for connections. This will only have an
522 effect if the buffer size is larger than the size that would otherwise be used
523 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
524 further information).
526 =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>
528 These options require or disable the use of the specified SSL or TLS protocols.
529 By default B<s_server> will negotiate the highest mutually supported protocol
531 When a specific TLS version is required, only that version will be accepted
536 There are several known bug in SSL and TLS implementations. Adding this
537 option enables various workarounds.
541 Disable negotiation of TLS compression.
542 TLS compression is not recommended and is off by default as of
547 Enable negotiation of TLS compression.
548 This option was introduced in OpenSSL 1.1.0.
549 TLS compression is not recommended and is off by default as of
554 Disable RFC4507bis session ticket support.
558 Use the server's cipher preferences, rather than the client's preferences.
560 =item B<-prioritize_chacha>
562 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
564 =item B<-no_resumption_on_reneg>
566 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
568 =item B<-client_sigalgs val>
570 Signature algorithms to support for client certificate authentication
571 (colon-separated list).
573 =item B<-named_curve val>
575 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
576 For a list of all possible curves, use:
578 $ openssl ecparam -list_curves
582 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
583 modified. This list is combined with any TLSv1.3 ciphersuites that have been
584 configured. When the client sends a list of supported ciphers the first client
585 cipher also included in the server list is used. Because the client specifies
586 the preference order, the order of the server cipherlist is irrelevant. See
587 the B<ciphers> command for more information.
589 =item B<-ciphersuites val>
591 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
592 This list is combined with any TLSv1.2 and below ciphersuites that have been
593 configured. When the client sends a list of supported ciphers the first client
594 cipher also included in the server list is used. Because the client specifies
595 the preference order, the order of the server cipherlist is irrelevant. See
596 the B<ciphers> command for more information. The format for this list is a
597 simple colon (":") separated list of TLSv1.3 ciphersuite names.
599 =item B<-dhparam infile>
601 The DH parameter file to use. The ephemeral DH cipher suites generate keys
602 using a set of DH parameters. If not specified then an attempt is made to
603 load the parameters from the server certificate file.
604 If this fails then a static set of parameters hard coded into the B<s_server>
605 program will be used.
607 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
608 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
609 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
610 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
611 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
612 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
613 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
615 Set different peer certificate verification options.
616 See the L<verify(1)> manual page for details.
618 =item B<-crl_check>, B<-crl_check_all>
620 Check the peer certificate has not been revoked by its CA.
621 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
622 option all CRLs of all CAs in the chain are checked.
626 Turns on non blocking I/O.
628 =item B<-psk_identity val>
630 Expect the client to send PSK identity B<val> when using a PSK
631 cipher suite, and warn if they do not. By default, the expected PSK
632 identity is the string "Client_identity".
634 =item B<-psk_hint val>
636 Use the PSK identity hint B<val> when using a PSK cipher suite.
640 Use the PSK key B<val> when using a PSK cipher suite. The key is
641 given as a hexadecimal number without leading 0x, for example -psk
643 This option must be provided in order to use a PSK cipher.
645 =item B<-psk_session file>
647 Use the pem encoded SSL_SESSION data stored in B<file> as the basis of a PSK.
648 Note that this will only work if TLSv1.3 is negotiated.
652 This option can only be used in conjunction with one of the DTLS options above.
653 With this option B<s_server> will listen on a UDP port for incoming connections.
654 Any ClientHellos that arrive will be checked to see if they have a cookie in
656 Any without a cookie will be responded to with a HelloVerifyRequest.
657 If a ClientHello with a cookie is received then B<s_server> will connect to
658 that peer and complete the handshake.
660 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
662 These options make B<s_server> use DTLS protocols instead of TLS.
663 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
664 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
669 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
670 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
671 available where OpenSSL has support for SCTP enabled.
675 If this option is set then no DH parameters will be loaded effectively
676 disabling the ephemeral DH cipher suites.
678 =item B<-alpn val>, B<-nextprotoneg val>
680 These flags enable the Enable the Application-Layer Protocol Negotiation
681 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
682 IETF standard and replaces NPN.
683 The B<val> list is a comma-separated list of supported protocol
684 names. The list should contain the most desirable protocols first.
685 Protocol names are printable ASCII strings, for example "http/1.1" or
687 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
691 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
692 to attempt to obtain a functional reference to the specified engine,
693 thus initialising it if needed. The engine will then be set as the default
694 for all available algorithms.
696 =item B<-keylogfile outfile>
698 Appends TLS secrets to the specified keylog file such that external programs
699 (like Wireshark) can decrypt TLS connections.
701 =item B<-max_early_data int>
703 Change the default maximum early data bytes that are specified for new sessions
704 and any incoming early data (when used in conjunction with the B<-early_data>
705 flag). The default value is approximately 16k. The argument must be an integer
706 greater than or equal to 0.
710 Accept early data where possible.
714 =head1 CONNECTED COMMANDS
716 If a connection request is established with an SSL client and neither the
717 B<-www> nor the B<-WWW> option has been used then normally any data received
718 from the client is displayed and any key presses will be sent to the client.
720 Certain commands are also recognized which perform special operations. These
721 commands are a letter which must appear at the start of a line. They are listed
728 End the current SSL connection but still accept new connections.
732 End the current SSL connection and exit.
736 Renegotiate the SSL session (TLSv1.2 and below only).
740 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
745 Send some plain text down the underlying TCP connection: this should
746 cause the client to disconnect due to a protocol violation.
750 Print out some session cache status information.
754 Send a heartbeat message to the client (DTLS only)
758 Send a key update message to the client (TLSv1.3 only)
762 Send a key update message to the client and request one back (TLSv1.3 only)
766 Send a certificate request to the client (TLSv1.3 only)
772 B<s_server> can be used to debug SSL clients. To accept connections from
773 a web browser the command:
775 openssl s_server -accept 443 -www
777 can be used for example.
779 Although specifying an empty list of CAs when requesting a client certificate
780 is strictly speaking a protocol violation, some SSL clients interpret this to
781 mean any CA is acceptable. This is useful for debugging purposes.
783 The session parameters can printed out using the B<sess_id> program.
787 Because this program has a lot of options and also because some of the
788 techniques used are rather old, the C source of B<s_server> is rather hard to
789 read and not a model of how things should be done.
790 A typical SSL server program would be much simpler.
792 The output of common ciphers is wrong: it just gives the list of ciphers that
793 OpenSSL recognizes and the client supports.
795 There should be a way for the B<s_server> program to print out details of any
796 unknown cipher suites a client says it supports.
800 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
801 L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>
802 L<SSL_CTX_set_max_pipelines(3)>
806 The -no_alt_chains option was first added to OpenSSL 1.1.0.
808 The -allow-no-dhe-kex and -prioritize_chacha options were first added to
813 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
815 Licensed under the OpenSSL license (the "License"). You may not use
816 this file except in compliance with the License. You can obtain a copy
817 in the file LICENSE in the source distribution or at
818 L<https://www.openssl.org/source/license.html>.