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<-srpvfile infile>]
161 [B<-srpuserseed val>]
175 [B<-nextprotoneg val>]
179 [B<-keylogfile outfile>]
180 [B<-max_early_data int>]
185 The B<s_server> command implements a generic SSL/TLS server which listens
186 for connections on a given port using SSL/TLS.
190 In addition to the options below the B<s_server> utility also supports the
191 common and server only options documented in the
192 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
199 Print out a usage message.
203 The TCP port to listen on for connections. If not specified 4433 is used.
207 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
211 Unix domain socket to accept on.
223 For -unix, unlink any existing socket first.
225 =item B<-context val>
227 Sets the SSL context id. It can be given any string value. If this option
228 is not present a default value will be used.
230 =item B<-verify int>, B<-Verify int>
232 The verify depth to use. This specifies the maximum length of the
233 client certificate chain and makes the server request a certificate from
234 the client. With the B<-verify> option a certificate is requested but the
235 client does not have to send one, with the B<-Verify> option the client
236 must supply a certificate or an error occurs.
238 If the cipher suite cannot request a client certificate (for example an
239 anonymous cipher suite or PSK) this option has no effect.
241 =item B<-cert infile>
243 The certificate to use, most servers cipher suites require the use of a
244 certificate and some require a certificate with a certain public key type:
245 for example the DSS cipher suites require a certificate containing a DSS
246 (DSA) key. If not specified then the filename "server.pem" will be used.
248 =item B<-nameopt val>
250 Option which determines how the subject or issuer names are displayed. The
251 B<val> argument can be a single option or multiple options separated by
252 commas. Alternatively the B<-nameopt> switch may be used more than once to
253 set multiple options. See the L<x509(1)> manual page for details.
255 =item B<-naccept +int>
257 The server will exit after receiving the specified number of connections,
260 =item B<-serverinfo val>
262 A file containing one or more blocks of PEM data. Each PEM block
263 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
264 followed by "length" bytes of extension data). If the client sends
265 an empty TLS ClientHello extension matching the type, the corresponding
266 ServerHello extension will be returned.
268 =item B<-certform PEM|DER>
270 The certificate format to use: DER or PEM. PEM is the default.
274 The private key to use. If not specified then the certificate file will
277 =item B<-keyform format>
279 The private format to use: DER or PEM. PEM is the default.
283 The private key password source. For more information about the format of B<val>
284 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
286 =item B<-dcert infile>, B<-dkey infile>
288 Specify an additional certificate and private key, these behave in the
289 same manner as the B<-cert> and B<-key> options except there is no default
290 if they are not specified (no additional certificate and key is used). As
291 noted above some cipher suites require a certificate containing a key of
292 a certain type. Some cipher suites need a certificate carrying an RSA key
293 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
294 a server can support clients which only support RSA or DSS cipher suites
295 by using an appropriate certificate.
297 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
299 Additional certificate and private key format and passphrase respectively.
303 Tests non blocking I/O.
307 This option translated a line feed from the terminal into CR+LF.
311 Print extensive debugging information including a hex dump of all traffic.
315 Show all protocol messages with hex dump.
317 =item B<-msgfile outfile>
319 File to send output of B<-msg> or B<-trace> to, default standard output.
323 Prints the SSL session states.
325 =item B<-CAfile infile>
327 A file containing trusted certificates to use during client authentication
328 and to use when attempting to build the server certificate chain. The list
329 is also used in the list of acceptable client CAs passed to the client when
330 a certificate is requested.
334 The directory to use for client certificate verification. This directory
335 must be in "hash format", see B<verify> for more information. These are
336 also used when building the server certificate chain.
340 Do not load the trusted CA certificates from the default file location.
344 Do not load the trusted CA certificates from the default directory location.
348 If this option is set then no certificate is used. This restricts the
349 cipher suites available to the anonymous ones (currently just anonymous
354 Inhibit printing of session and certificate information.
358 Sends a status message back to the client when it connects. This includes
359 information about the ciphers used and various session parameters.
360 The output is in HTML format so this option will normally be used with a
365 Emulates a simple web server. Pages will be resolved relative to the
366 current directory, for example if the URL https://myhost/page.html is
367 requested the file ./page.html will be loaded.
369 =item B<-tlsextdebug>
371 Print a hex dump of any TLS extensions received from the server.
375 Emulates a simple web server. Pages will be resolved relative to the
376 current directory, for example if the URL https://myhost/page.html is
377 requested the file ./page.html will be loaded. The files loaded are
378 assumed to contain a complete and correct HTTP response (lines that
379 are part of the HTTP response line and headers must end with CRLF).
381 =item B<-id_prefix val>
383 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
384 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
385 servers, when each of which might be generating a unique range of session
386 IDs (eg. with a certain prefix).
388 =item B<-rand file...>
390 A file or files containing random data used to seed the random number
392 Multiple files can be specified separated by an OS-dependent character.
393 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
396 =item [B<-writerand file>]
398 Writes random data to the specified I<file> upon exit.
399 This can be used with a subsequent B<-rand> flag.
401 =item B<-verify_return_error>
403 Verification errors normally just print a message but allow the
404 connection to continue, for debugging purposes.
405 If this option is used, then verification errors close the connection.
409 Enables certificate status request support (aka OCSP stapling).
411 =item B<-status_verbose>
413 Enables certificate status request support (aka OCSP stapling) and gives
414 a verbose printout of the OCSP response.
416 =item B<-status_timeout int>
418 Sets the timeout for OCSP response to B<int> seconds.
420 =item B<-status_url val>
422 Sets a fallback responder URL to use if no responder URL is present in the
423 server certificate. Without this option an error is returned if the server
424 certificate does not contain a responder address.
426 =item B<-status_file infile>
428 Overrides any OCSP responder URLs from the certificate and always provides the
429 OCSP Response stored in the file. The file must be in DER format.
433 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
434 with B<enable-ssl-trace> for this option to work.
438 Provide a brief summary of connection parameters instead of the normal verbose
443 Simple test server which just reverses the text received from the client
444 and sends it back to the server. Also sets B<-brief>.
448 Switch on asynchronous mode. Cryptographic operations will be performed
449 asynchronously. This will only have an effect if an asynchronous capable engine
450 is also used via the B<-engine> option. For test purposes the dummy async engine
451 (dasync) can be used (if available).
453 =item B<-max_send_frag +int>
455 The maximum size of data fragment to send.
456 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
458 =item B<-split_send_frag +int>
460 The size used to split data for encrypt pipelines. If more data is written in
461 one go than this value then it will be split into multiple pipelines, up to the
462 maximum number of pipelines defined by max_pipelines. This only has an effect if
463 a suitable cipher suite has been negotiated, an engine that supports pipelining
464 has been loaded, and max_pipelines is greater than 1. See
465 L<SSL_CTX_set_split_send_fragment(3)> for further information.
467 =item B<-max_pipelines +int>
469 The maximum number of encrypt/decrypt pipelines to be used. This will only have
470 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
471 engine) and a suitable cipher suite has been negotiated. The default value is 1.
472 See L<SSL_CTX_set_max_pipelines(3)> for further information.
474 =item B<-read_buf +int>
476 The default read buffer size to be used for connections. This will only have an
477 effect if the buffer size is larger than the size that would otherwise be used
478 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
479 further information).
481 =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>
483 These options require or disable the use of the specified SSL or TLS protocols.
484 By default B<s_server> will negotiate the highest mutually supported protocol
486 When a specific TLS version is required, only that version will be accepted
491 There are several known bug in SSL and TLS implementations. Adding this
492 option enables various workarounds.
496 Disable negotiation of TLS compression.
497 TLS compression is not recommended and is off by default as of
502 Enable negotiation of TLS compression.
503 This option was introduced in OpenSSL 1.1.0.
504 TLS compression is not recommended and is off by default as of
509 Disable RFC4507bis session ticket support.
513 Use the server's cipher preferences, rather than the client's preferences.
515 =item B<-prioritize_chacha>
517 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
519 =item B<-no_resumption_on_reneg>
521 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
523 =item B<-client_sigalgs val>
525 Signature algorithms to support for client certificate authentication
526 (colon-separated list).
528 =item B<-named_curve val>
530 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
531 For a list of all possible curves, use:
533 $ openssl ecparam -list_curves
537 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
538 modified. This list is combined with any TLSv1.3 ciphersuites that have been
539 configured. When the client sends a list of supported ciphers the first client
540 cipher also included in the server list is used. Because the client specifies
541 the preference order, the order of the server cipherlist is irrelevant. See
542 the B<ciphers> command for more information.
544 =item B<-ciphersuites val>
546 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
547 This list is combined with any TLSv1.2 and below ciphersuites that have been
548 configured. When the client sends a list of supported ciphers the first client
549 cipher also included in the server list is used. Because the client specifies
550 the preference order, the order of the server cipherlist is irrelevant. See
551 the B<ciphers> command for more information. The format for this list is a
552 simple colon (":") separated list of TLSv1.3 ciphersuite names.
554 =item B<-dhparam infile>
556 The DH parameter file to use. The ephemeral DH cipher suites generate keys
557 using a set of DH parameters. If not specified then an attempt is made to
558 load the parameters from the server certificate file.
559 If this fails then a static set of parameters hard coded into the B<s_server>
560 program will be used.
562 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
563 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
564 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
565 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
566 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
567 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
568 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
570 Set different peer certificate verification options.
571 See the L<verify(1)> manual page for details.
573 =item B<-crl_check>, B<-crl_check_all>
575 Check the peer certificate has not been revoked by its CA.
576 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
577 option all CRLs of all CAs in the chain are checked.
581 Turns on non blocking I/O.
583 =item B<-psk_identity val>
585 Expect the client to send PSK identity B<val> when using a PSK
586 cipher suite, and warn if they do not. By default, the expected PSK
587 identity is the string "Client_identity".
589 =item B<-psk_hint val>
591 Use the PSK identity hint B<val> when using a PSK cipher suite.
595 Use the PSK key B<val> when using a PSK cipher suite. The key is
596 given as a hexadecimal number without leading 0x, for example -psk
598 This option must be provided in order to use a PSK cipher.
602 This option can only be used in conjunction with one of the DTLS options above.
603 With this option B<s_server> will listen on a UDP port for incoming connections.
604 Any ClientHellos that arrive will be checked to see if they have a cookie in
606 Any without a cookie will be responded to with a HelloVerifyRequest.
607 If a ClientHello with a cookie is received then B<s_server> will connect to
608 that peer and complete the handshake.
610 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
612 These options make B<s_server> use DTLS protocols instead of TLS.
613 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
614 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
619 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
620 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
621 available where OpenSSL has support for SCTP enabled.
625 If this option is set then no DH parameters will be loaded effectively
626 disabling the ephemeral DH cipher suites.
628 =item B<-alpn val>, B<-nextprotoneg val>
630 These flags enable the Enable the Application-Layer Protocol Negotiation
631 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
632 IETF standard and replaces NPN.
633 The B<val> list is a comma-separated list of supported protocol
634 names. The list should contain the most desirable protocols first.
635 Protocol names are printable ASCII strings, for example "http/1.1" or
637 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
641 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
642 to attempt to obtain a functional reference to the specified engine,
643 thus initialising it if needed. The engine will then be set as the default
644 for all available algorithms.
646 =item B<-keylogfile outfile>
648 Appends TLS secrets to the specified keylog file such that external programs
649 (like Wireshark) can decrypt TLS connections.
651 =item B<-max_early_data int>
653 Change the default maximum early data bytes that are specified for new sessions
654 and any incoming early data (when used in conjunction with the B<-early_data>
655 flag). The default value is approximately 16k. The argument must be an integer
656 greater than or equal to 0.
660 Accept early data where possible.
664 =head1 CONNECTED COMMANDS
666 If a connection request is established with an SSL client and neither the
667 B<-www> nor the B<-WWW> option has been used then normally any data received
668 from the client is displayed and any key presses will be sent to the client.
670 Certain single letter commands are also recognized which perform special
671 operations: these are listed below.
677 End the current SSL connection but still accept new connections.
681 End the current SSL connection and exit.
685 Renegotiate the SSL session.
689 Renegotiate the SSL session and request a client certificate.
693 Send some plain text down the underlying TCP connection: this should
694 cause the client to disconnect due to a protocol violation.
698 Print out some session cache status information.
704 B<s_server> can be used to debug SSL clients. To accept connections from
705 a web browser the command:
707 openssl s_server -accept 443 -www
709 can be used for example.
711 Although specifying an empty list of CAs when requesting a client certificate
712 is strictly speaking a protocol violation, some SSL clients interpret this to
713 mean any CA is acceptable. This is useful for debugging purposes.
715 The session parameters can printed out using the B<sess_id> program.
719 Because this program has a lot of options and also because some of the
720 techniques used are rather old, the C source of B<s_server> is rather hard to
721 read and not a model of how things should be done.
722 A typical SSL server program would be much simpler.
724 The output of common ciphers is wrong: it just gives the list of ciphers that
725 OpenSSL recognizes and the client supports.
727 There should be a way for the B<s_server> program to print out details of any
728 unknown cipher suites a client says it supports.
732 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
733 L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>
734 L<SSL_CTX_set_max_pipelines(3)>
738 The -no_alt_chains option was first added to OpenSSL 1.1.0.
740 The -allow-no-dhe-kex and -prioritize_chacha options were first added to
745 Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
747 Licensed under the OpenSSL license (the "License"). You may not use
748 this file except in compliance with the License. You can obtain a copy
749 in the file LICENSE in the source distribution or at
750 L<https://www.openssl.org/source/license.html>.