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.
249 =item B<-nameopt val>
251 Option which determines how the subject or issuer names are displayed. The
252 B<val> argument can be a single option or multiple options separated by
253 commas. Alternatively the B<-nameopt> switch may be used more than once to
254 set multiple options. See the L<x509(1)> manual page for details.
256 =item B<-naccept +int>
258 The server will exit after receiving the specified number of connections,
261 =item B<-serverinfo val>
263 A file containing one or more blocks of PEM data. Each PEM block
264 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
265 followed by "length" bytes of extension data). If the client sends
266 an empty TLS ClientHello extension matching the type, the corresponding
267 ServerHello extension will be returned.
269 =item B<-certform PEM|DER>
271 The certificate format to use: DER or PEM. PEM is the default.
275 The private key to use. If not specified then the certificate file will
278 =item B<-keyform format>
280 The private format to use: DER or PEM. PEM is the default.
284 The private key password source. For more information about the format of B<val>
285 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
287 =item B<-dcert infile>, B<-dkey infile>
289 Specify an additional certificate and private key, these behave in the
290 same manner as the B<-cert> and B<-key> options except there is no default
291 if they are not specified (no additional certificate and key is used). As
292 noted above some cipher suites require a certificate containing a key of
293 a certain type. Some cipher suites need a certificate carrying an RSA key
294 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
295 a server can support clients which only support RSA or DSS cipher suites
296 by using an appropriate certificate.
298 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
300 Additional certificate and private key format and passphrase respectively.
304 Tests non blocking I/O.
308 This option translated a line feed from the terminal into CR+LF.
312 Print extensive debugging information including a hex dump of all traffic.
316 Show all protocol messages with hex dump.
318 =item B<-msgfile outfile>
320 File to send output of B<-msg> or B<-trace> to, default standard output.
324 Prints the SSL session states.
326 =item B<-CAfile infile>
328 A file containing trusted certificates to use during client authentication
329 and to use when attempting to build the server certificate chain. The list
330 is also used in the list of acceptable client CAs passed to the client when
331 a certificate is requested.
335 The directory to use for client certificate verification. This directory
336 must be in "hash format", see B<verify> for more information. These are
337 also used when building the server certificate chain.
341 Do not load the trusted CA certificates from the default file location.
345 Do not load the trusted CA certificates from the default directory location.
349 If this option is set then no certificate is used. This restricts the
350 cipher suites available to the anonymous ones (currently just anonymous
355 Inhibit printing of session and certificate information.
359 Sends a status message back to the client when it connects. This includes
360 information about the ciphers used and various session parameters.
361 The output is in HTML format so this option will normally be used with a
366 Emulates a simple web server. Pages will be resolved relative to the
367 current directory, for example if the URL https://myhost/page.html is
368 requested the file ./page.html will be loaded.
370 =item B<-tlsextdebug>
372 Print a hex dump of any TLS extensions received from the server.
376 Emulates a simple web server. Pages will be resolved relative to the
377 current directory, for example if the URL https://myhost/page.html is
378 requested the file ./page.html will be loaded. The files loaded are
379 assumed to contain a complete and correct HTTP response (lines that
380 are part of the HTTP response line and headers must end with CRLF).
382 =item B<-id_prefix val>
384 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
385 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
386 servers, when each of which might be generating a unique range of session
387 IDs (eg. with a certain prefix).
389 =item B<-rand file...>
391 A file or files containing random data used to seed the random number
393 Multiple files can be specified separated by an OS-dependent character.
394 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
397 =item [B<-writerand file>]
399 Writes random data to the specified I<file> upon exit.
400 This can be used with a subsequent B<-rand> flag.
402 =item B<-verify_return_error>
404 Verification errors normally just print a message but allow the
405 connection to continue, for debugging purposes.
406 If this option is used, then verification errors close the connection.
410 Enables certificate status request support (aka OCSP stapling).
412 =item B<-status_verbose>
414 Enables certificate status request support (aka OCSP stapling) and gives
415 a verbose printout of the OCSP response.
417 =item B<-status_timeout int>
419 Sets the timeout for OCSP response to B<int> seconds.
421 =item B<-status_url val>
423 Sets a fallback responder URL to use if no responder URL is present in the
424 server certificate. Without this option an error is returned if the server
425 certificate does not contain a responder address.
427 =item B<-status_file infile>
429 Overrides any OCSP responder URLs from the certificate and always provides the
430 OCSP Response stored in the file. The file must be in DER format.
434 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
435 with B<enable-ssl-trace> for this option to work.
439 Provide a brief summary of connection parameters instead of the normal verbose
444 Simple test server which just reverses the text received from the client
445 and sends it back to the server. Also sets B<-brief>.
449 Switch on asynchronous mode. Cryptographic operations will be performed
450 asynchronously. This will only have an effect if an asynchronous capable engine
451 is also used via the B<-engine> option. For test purposes the dummy async engine
452 (dasync) can be used (if available).
454 =item B<-max_send_frag +int>
456 The maximum size of data fragment to send.
457 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
459 =item B<-split_send_frag +int>
461 The size used to split data for encrypt pipelines. If more data is written in
462 one go than this value then it will be split into multiple pipelines, up to the
463 maximum number of pipelines defined by max_pipelines. This only has an effect if
464 a suitable cipher suite has been negotiated, an engine that supports pipelining
465 has been loaded, and max_pipelines is greater than 1. See
466 L<SSL_CTX_set_split_send_fragment(3)> for further information.
468 =item B<-max_pipelines +int>
470 The maximum number of encrypt/decrypt pipelines to be used. This will only have
471 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
472 engine) and a suitable cipher suite has been negotiated. The default value is 1.
473 See L<SSL_CTX_set_max_pipelines(3)> for further information.
475 =item B<-read_buf +int>
477 The default read buffer size to be used for connections. This will only have an
478 effect if the buffer size is larger than the size that would otherwise be used
479 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
480 further information).
482 =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>
484 These options require or disable the use of the specified SSL or TLS protocols.
485 By default B<s_server> will negotiate the highest mutually supported protocol
487 When a specific TLS version is required, only that version will be accepted
492 There are several known bug in SSL and TLS implementations. Adding this
493 option enables various workarounds.
497 Disable negotiation of TLS compression.
498 TLS compression is not recommended and is off by default as of
503 Enable negotiation of TLS compression.
504 This option was introduced in OpenSSL 1.1.0.
505 TLS compression is not recommended and is off by default as of
510 Disable RFC4507bis session ticket support.
514 Use the server's cipher preferences, rather than the client's preferences.
516 =item B<-prioritize_chacha>
518 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
520 =item B<-no_resumption_on_reneg>
522 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
524 =item B<-client_sigalgs val>
526 Signature algorithms to support for client certificate authentication
527 (colon-separated list).
529 =item B<-named_curve val>
531 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
532 For a list of all possible curves, use:
534 $ openssl ecparam -list_curves
538 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
539 modified. This list is combined with any TLSv1.3 ciphersuites that have been
540 configured. When the client sends a list of supported ciphers the first client
541 cipher also included in the server list is used. Because the client specifies
542 the preference order, the order of the server cipherlist is irrelevant. See
543 the B<ciphers> command for more information.
545 =item B<-ciphersuites val>
547 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
548 This list is combined with any TLSv1.2 and below ciphersuites that have been
549 configured. When the client sends a list of supported ciphers the first client
550 cipher also included in the server list is used. Because the client specifies
551 the preference order, the order of the server cipherlist is irrelevant. See
552 the B<ciphers> command for more information. The format for this list is a
553 simple colon (":") separated list of TLSv1.3 ciphersuite names.
555 =item B<-dhparam infile>
557 The DH parameter file to use. The ephemeral DH cipher suites generate keys
558 using a set of DH parameters. If not specified then an attempt is made to
559 load the parameters from the server certificate file.
560 If this fails then a static set of parameters hard coded into the B<s_server>
561 program will be used.
563 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
564 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
565 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
566 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
567 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
568 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
569 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
571 Set different peer certificate verification options.
572 See the L<verify(1)> manual page for details.
574 =item B<-crl_check>, B<-crl_check_all>
576 Check the peer certificate has not been revoked by its CA.
577 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
578 option all CRLs of all CAs in the chain are checked.
582 Turns on non blocking I/O.
584 =item B<-psk_identity val>
586 Expect the client to send PSK identity B<val> when using a PSK
587 cipher suite, and warn if they do not. By default, the expected PSK
588 identity is the string "Client_identity".
590 =item B<-psk_hint val>
592 Use the PSK identity hint B<val> when using a PSK cipher suite.
596 Use the PSK key B<val> when using a PSK cipher suite. The key is
597 given as a hexadecimal number without leading 0x, for example -psk
599 This option must be provided in order to use a PSK cipher.
601 =item B<-psk_session file>
603 Use the pem encoded SSL_SESSION data stored in B<file> as the basis of a PSK.
604 Note that this will only work if TLSv1.3 is negotiated.
608 This option can only be used in conjunction with one of the DTLS options above.
609 With this option B<s_server> will listen on a UDP port for incoming connections.
610 Any ClientHellos that arrive will be checked to see if they have a cookie in
612 Any without a cookie will be responded to with a HelloVerifyRequest.
613 If a ClientHello with a cookie is received then B<s_server> will connect to
614 that peer and complete the handshake.
616 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
618 These options make B<s_server> use DTLS protocols instead of TLS.
619 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
620 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
625 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
626 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
627 available where OpenSSL has support for SCTP enabled.
631 If this option is set then no DH parameters will be loaded effectively
632 disabling the ephemeral DH cipher suites.
634 =item B<-alpn val>, B<-nextprotoneg val>
636 These flags enable the Enable the Application-Layer Protocol Negotiation
637 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
638 IETF standard and replaces NPN.
639 The B<val> list is a comma-separated list of supported protocol
640 names. The list should contain the most desirable protocols first.
641 Protocol names are printable ASCII strings, for example "http/1.1" or
643 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
647 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
648 to attempt to obtain a functional reference to the specified engine,
649 thus initialising it if needed. The engine will then be set as the default
650 for all available algorithms.
652 =item B<-keylogfile outfile>
654 Appends TLS secrets to the specified keylog file such that external programs
655 (like Wireshark) can decrypt TLS connections.
657 =item B<-max_early_data int>
659 Change the default maximum early data bytes that are specified for new sessions
660 and any incoming early data (when used in conjunction with the B<-early_data>
661 flag). The default value is approximately 16k. The argument must be an integer
662 greater than or equal to 0.
666 Accept early data where possible.
670 =head1 CONNECTED COMMANDS
672 If a connection request is established with an SSL client and neither the
673 B<-www> nor the B<-WWW> option has been used then normally any data received
674 from the client is displayed and any key presses will be sent to the client.
676 Certain single letter commands are also recognized which perform special
677 operations: these are listed below.
683 End the current SSL connection but still accept new connections.
687 End the current SSL connection and exit.
691 Renegotiate the SSL session.
695 Renegotiate the SSL session and request a client certificate.
699 Send some plain text down the underlying TCP connection: this should
700 cause the client to disconnect due to a protocol violation.
704 Print out some session cache status information.
710 B<s_server> can be used to debug SSL clients. To accept connections from
711 a web browser the command:
713 openssl s_server -accept 443 -www
715 can be used for example.
717 Although specifying an empty list of CAs when requesting a client certificate
718 is strictly speaking a protocol violation, some SSL clients interpret this to
719 mean any CA is acceptable. This is useful for debugging purposes.
721 The session parameters can printed out using the B<sess_id> program.
725 Because this program has a lot of options and also because some of the
726 techniques used are rather old, the C source of B<s_server> is rather hard to
727 read and not a model of how things should be done.
728 A typical SSL server program would be much simpler.
730 The output of common ciphers is wrong: it just gives the list of ciphers that
731 OpenSSL recognizes and the client supports.
733 There should be a way for the B<s_server> program to print out details of any
734 unknown cipher suites a client says it supports.
738 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
739 L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>
740 L<SSL_CTX_set_max_pipelines(3)>
744 The -no_alt_chains option was first added to OpenSSL 1.1.0.
746 The -allow-no-dhe-kex and -prioritize_chacha options were first added to
751 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
753 Licensed under the OpenSSL license (the "License"). You may not use
754 this file except in compliance with the License. You can obtain a copy
755 in the file LICENSE in the source distribution or at
756 L<https://www.openssl.org/source/license.html>.