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>]
117 [B<-record_padding val>]
118 [B<-debug_broken_protocol>]
121 [B<-verify_name val>]
122 [B<-verify_depth int>]
125 [B<-verify_hostname val>]
126 [B<-verify_email val>]
128 [B<-ignore_critical>]
133 [B<-explicit_policy>]
142 [B<-suiteB_128_only>]
148 [B<-allow_proxy_certs>]
153 [B<-xcertform PEM|DER>]
154 [B<-xkeyform PEM|DER>]
156 [B<-psk_identity val>]
159 [B<-srpvfile infile>]
160 [B<-srpuserseed val>]
174 [B<-nextprotoneg val>]
178 [B<-keylogfile outfile>]
179 [B<-max_early_data int>]
184 The B<s_server> command implements a generic SSL/TLS server which listens
185 for connections on a given port using SSL/TLS.
189 In addition to the options below the B<s_server> utility also supports the
190 common and server only options documented in the
191 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
198 Print out a usage message.
202 The TCP port to listen on for connections. If not specified 4433 is used.
206 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
210 Unix domain socket to accept on.
222 For -unix, unlink any existing socket first.
224 =item B<-context val>
226 Sets the SSL context id. It can be given any string value. If this option
227 is not present a default value will be used.
229 =item B<-verify int>, B<-Verify int>
231 The verify depth to use. This specifies the maximum length of the
232 client certificate chain and makes the server request a certificate from
233 the client. With the B<-verify> option a certificate is requested but the
234 client does not have to send one, with the B<-Verify> option the client
235 must supply a certificate or an error occurs.
237 If the cipher suite cannot request a client certificate (for example an
238 anonymous cipher suite or PSK) this option has no effect.
240 =item B<-cert infile>
242 The certificate to use, most servers cipher suites require the use of a
243 certificate and some require a certificate with a certain public key type:
244 for example the DSS cipher suites require a certificate containing a DSS
245 (DSA) key. If not specified then the filename "server.pem" will be used.
247 =item B<-nameopt val>
249 Option which determines how the subject or issuer names are displayed. The
250 B<val> argument can be a single option or multiple options separated by
251 commas. Alternatively the B<-nameopt> switch may be used more than once to
252 set multiple options. See the L<x509(1)> manual page for details.
254 =item B<-naccept +int>
256 The server will exit after receiving the specified number of connections,
259 =item B<-serverinfo val>
261 A file containing one or more blocks of PEM data. Each PEM block
262 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
263 followed by "length" bytes of extension data). If the client sends
264 an empty TLS ClientHello extension matching the type, the corresponding
265 ServerHello extension will be returned.
267 =item B<-certform PEM|DER>
269 The certificate format to use: DER or PEM. PEM is the default.
273 The private key to use. If not specified then the certificate file will
276 =item B<-keyform format>
278 The private format to use: DER or PEM. PEM is the default.
282 The private key password source. For more information about the format of B<val>
283 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
285 =item B<-dcert infile>, B<-dkey infile>
287 Specify an additional certificate and private key, these behave in the
288 same manner as the B<-cert> and B<-key> options except there is no default
289 if they are not specified (no additional certificate and key is used). As
290 noted above some cipher suites require a certificate containing a key of
291 a certain type. Some cipher suites need a certificate carrying an RSA key
292 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
293 a server can support clients which only support RSA or DSS cipher suites
294 by using an appropriate certificate.
296 =item B<-dcertform PEM|DER>, B<-dkeyform PEM|DER>, B<-dpass val>
298 Additional certificate and private key format and passphrase respectively.
302 Tests non blocking I/O.
306 This option translated a line feed from the terminal into CR+LF.
310 Print extensive debugging information including a hex dump of all traffic.
314 Show all protocol messages with hex dump.
316 =item B<-msgfile outfile>
318 File to send output of B<-msg> or B<-trace> to, default standard output.
322 Prints the SSL session states.
324 =item B<-CAfile infile>
326 A file containing trusted certificates to use during client authentication
327 and to use when attempting to build the server certificate chain. The list
328 is also used in the list of acceptable client CAs passed to the client when
329 a certificate is requested.
333 The directory to use for client certificate verification. This directory
334 must be in "hash format", see B<verify> for more information. These are
335 also used when building the server certificate chain.
339 Do not load the trusted CA certificates from the default file location.
343 Do not load the trusted CA certificates from the default directory location.
347 If this option is set then no certificate is used. This restricts the
348 cipher suites available to the anonymous ones (currently just anonymous
353 Inhibit printing of session and certificate information.
357 Sends a status message back to the client when it connects. This includes
358 information about the ciphers used and various session parameters.
359 The output is in HTML format so this option will normally be used with a
364 Emulates a simple web server. Pages will be resolved relative to the
365 current directory, for example if the URL https://myhost/page.html is
366 requested the file ./page.html will be loaded.
368 =item B<-tlsextdebug>
370 Print a hex dump of any TLS extensions received from the server.
374 Emulates a simple web server. Pages will be resolved relative to the
375 current directory, for example if the URL https://myhost/page.html is
376 requested the file ./page.html will be loaded. The files loaded are
377 assumed to contain a complete and correct HTTP response (lines that
378 are part of the HTTP response line and headers must end with CRLF).
380 =item B<-id_prefix val>
382 Generate SSL/TLS session IDs prefixed by B<val>. This is mostly useful
383 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
384 servers, when each of which might be generating a unique range of session
385 IDs (eg. with a certain prefix).
387 =item B<-rand file...>
389 A file or files containing random data used to seed the random number
391 Multiple files can be specified separated by an OS-dependent character.
392 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
395 =item [B<-writerand file>]
397 Writes random data to the specified I<file> upon exit.
398 This can be used with a subsequent B<-rand> flag.
400 =item B<-verify_return_error>
402 Verification errors normally just print a message but allow the
403 connection to continue, for debugging purposes.
404 If this option is used, then verification errors close the connection.
408 Enables certificate status request support (aka OCSP stapling).
410 =item B<-status_verbose>
412 Enables certificate status request support (aka OCSP stapling) and gives
413 a verbose printout of the OCSP response.
415 =item B<-status_timeout int>
417 Sets the timeout for OCSP response to B<int> seconds.
419 =item B<-status_url val>
421 Sets a fallback responder URL to use if no responder URL is present in the
422 server certificate. Without this option an error is returned if the server
423 certificate does not contain a responder address.
425 =item B<-status_file infile>
427 Overrides any OCSP responder URLs from the certificate and always provides the
428 OCSP Response stored in the file. The file must be in DER format.
432 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
433 with B<enable-ssl-trace> for this option to work.
437 Provide a brief summary of connection parameters instead of the normal verbose
442 Simple test server which just reverses the text received from the client
443 and sends it back to the server. Also sets B<-brief>.
447 Switch on asynchronous mode. Cryptographic operations will be performed
448 asynchronously. This will only have an effect if an asynchronous capable engine
449 is also used via the B<-engine> option. For test purposes the dummy async engine
450 (dasync) can be used (if available).
452 =item B<-max_send_frag +int>
454 The maximum size of data fragment to send.
455 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
457 =item B<-split_send_frag +int>
459 The size used to split data for encrypt pipelines. If more data is written in
460 one go than this value then it will be split into multiple pipelines, up to the
461 maximum number of pipelines defined by max_pipelines. This only has an effect if
462 a suitable cipher suite has been negotiated, an engine that supports pipelining
463 has been loaded, and max_pipelines is greater than 1. See
464 L<SSL_CTX_set_split_send_fragment(3)> for further information.
466 =item B<-max_pipelines +int>
468 The maximum number of encrypt/decrypt pipelines to be used. This will only have
469 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
470 engine) and a suitable cipher suite has been negotiated. The default value is 1.
471 See L<SSL_CTX_set_max_pipelines(3)> for further information.
473 =item B<-read_buf +int>
475 The default read buffer size to be used for connections. This will only have an
476 effect if the buffer size is larger than the size that would otherwise be used
477 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
478 further information).
480 =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>
482 These options require or disable the use of the specified SSL or TLS protocols.
483 By default B<s_server> will negotiate the highest mutually supported protocol
485 When a specific TLS version is required, only that version will be accepted
490 There are several known bug in SSL and TLS implementations. Adding this
491 option enables various workarounds.
495 Disable negotiation of TLS compression.
496 TLS compression is not recommended and is off by default as of
501 Enable negotiation of TLS compression.
502 This option was introduced in OpenSSL 1.1.0.
503 TLS compression is not recommended and is off by default as of
508 Disable RFC4507bis session ticket support.
512 Use the server's cipher preferences, rather than the client's preferences.
514 =item B<-prioritize_chacha>
516 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
518 =item B<-no_resumption_on_reneg>
520 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
522 =item B<-client_sigalgs val>
524 Signature algorithms to support for client certificate authentication
525 (colon-separated list).
527 =item B<-named_curve val>
529 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
530 For a list of all possible curves, use:
532 $ openssl ecparam -list_curves
536 This allows the cipher list used by the server to be modified. When
537 the client sends a list of supported ciphers the first client cipher
538 also included in the server list is used. Because the client specifies
539 the preference order, the order of the server cipherlist irrelevant. See
540 the B<ciphers> command for more information.
542 =item B<-dhparam infile>
544 The DH parameter file to use. The ephemeral DH cipher suites generate keys
545 using a set of DH parameters. If not specified then an attempt is made to
546 load the parameters from the server certificate file.
547 If this fails then a static set of parameters hard coded into the B<s_server>
548 program will be used.
550 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
551 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
552 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
553 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
554 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
555 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
556 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
558 Set different peer certificate verification options.
559 See the L<verify(1)> manual page for details.
561 =item B<-crl_check>, B<-crl_check_all>
563 Check the peer certificate has not been revoked by its CA.
564 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
565 option all CRLs of all CAs in the chain are checked.
569 Turns on non blocking I/O.
571 =item B<-psk_identity val>
573 Expect the client to send PSK identity B<val> when using a PSK
574 cipher suite, and warn if they do not. By default, the expected PSK
575 identity is the string "Client_identity".
577 =item B<-psk_hint val>
579 Use the PSK identity hint B<val> when using a PSK cipher suite.
583 Use the PSK key B<val> when using a PSK cipher suite. The key is
584 given as a hexadecimal number without leading 0x, for example -psk
586 This option must be provided in order to use a PSK cipher.
590 This option can only be used in conjunction with one of the DTLS options above.
591 With this option B<s_server> will listen on a UDP port for incoming connections.
592 Any ClientHellos that arrive will be checked to see if they have a cookie in
594 Any without a cookie will be responded to with a HelloVerifyRequest.
595 If a ClientHello with a cookie is received then B<s_server> will connect to
596 that peer and complete the handshake.
598 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
600 These options make B<s_server> use DTLS protocols instead of TLS.
601 With B<-dtls>, B<s_server> will negotiate any supported DTLS protocol version,
602 whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and DTLSv1.2
607 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
608 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
609 available where OpenSSL has support for SCTP enabled.
613 If this option is set then no DH parameters will be loaded effectively
614 disabling the ephemeral DH cipher suites.
616 =item B<-alpn val>, B<-nextprotoneg val>
618 These flags enable the Enable the Application-Layer Protocol Negotiation
619 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
620 IETF standard and replaces NPN.
621 The B<val> list is a comma-separated list of supported protocol
622 names. The list should contain the most desirable protocols first.
623 Protocol names are printable ASCII strings, for example "http/1.1" or
625 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
629 Specifying an engine (by its unique id string in B<val>) will cause B<s_server>
630 to attempt to obtain a functional reference to the specified engine,
631 thus initialising it if needed. The engine will then be set as the default
632 for all available algorithms.
634 =item B<-keylogfile outfile>
636 Appends TLS secrets to the specified keylog file such that external programs
637 (like Wireshark) can decrypt TLS connections.
639 =item B<-max_early_data int>
641 Change the default maximum early data bytes that are specified for new sessions
642 and any incoming early data (when used in conjunction with the B<-early_data>
643 flag). The default value is approximately 16k. The argument must be an integer
644 greater than or equal to 0.
648 Accept early data where possible.
652 =head1 CONNECTED COMMANDS
654 If a connection request is established with an SSL client and neither the
655 B<-www> nor the B<-WWW> option has been used then normally any data received
656 from the client is displayed and any key presses will be sent to the client.
658 Certain single letter commands are also recognized which perform special
659 operations: these are listed below.
665 End the current SSL connection but still accept new connections.
669 End the current SSL connection and exit.
673 Renegotiate the SSL session.
677 Renegotiate the SSL session and request a client certificate.
681 Send some plain text down the underlying TCP connection: this should
682 cause the client to disconnect due to a protocol violation.
686 Print out some session cache status information.
692 B<s_server> can be used to debug SSL clients. To accept connections from
693 a web browser the command:
695 openssl s_server -accept 443 -www
697 can be used for example.
699 Although specifying an empty list of CAs when requesting a client certificate
700 is strictly speaking a protocol violation, some SSL clients interpret this to
701 mean any CA is acceptable. This is useful for debugging purposes.
703 The session parameters can printed out using the B<sess_id> program.
707 Because this program has a lot of options and also because some of the
708 techniques used are rather old, the C source of B<s_server> is rather hard to
709 read and not a model of how things should be done.
710 A typical SSL server program would be much simpler.
712 The output of common ciphers is wrong: it just gives the list of ciphers that
713 OpenSSL recognizes and the client supports.
715 There should be a way for the B<s_server> program to print out details of any
716 unknown cipher suites a client says it supports.
720 L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_client(1)>, L<ciphers(1)>
721 L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>
722 L<SSL_CTX_set_max_pipelines(3)>
726 The -no_alt_chains option was first added to OpenSSL 1.1.0.
728 The -allow-no-dhe-kex and -prioritize_chacha options were first added to
733 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
735 Licensed under the OpenSSL license (the "License"). You may not use
736 this file except in compliance with the License. You can obtain a copy
737 in the file LICENSE in the source distribution or at
738 L<https://www.openssl.org/source/license.html>.