2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-s_server - SSL/TLS server program
10 B<openssl> B<s_server>
24 [B<-serverinfo> I<val>]
25 [B<-certform> B<DER>|B<PEM>]
27 [B<-keyform> B<DER>|B<PEM>]
30 [B<-dcertform> B<DER>|B<PEM>]
32 [B<-dkeyform> B<DER>|B<PEM>]
38 [B<-msgfile> I<outfile>]
42 [B<-no_resume_ephemeral>]
46 [B<-servername_fatal>]
51 [B<-id_prefix> I<val>]
52 [B<-keymatexport> I<val>]
53 [B<-keymatexportlen> I<+int>]
56 [B<-cert_chain> I<infile>]
57 [B<-dcert_chain> I<infile>]
58 [B<-chainCApath> I<dir>]
59 [B<-verifyCApath> I<dir>]
60 [B<-chainCAstore> I<uri>]
61 [B<-verifyCAstore> I<uri>]
64 [B<-verify_return_error>]
67 [B<-chainCAfile> I<infile>]
68 [B<-verifyCAfile> I<infile>]
73 [B<-status_timeout> I<int>]
74 [B<-status_url> I<val>]
75 [B<-status_file> I<infile>]
78 [B<-security_debug_verbose>]
82 [B<-ssl_config> I<val>]
83 [B<-max_send_frag> I<+int>]
84 [B<-split_send_frag> I<+int>]
85 [B<-max_pipelines> I<+int>]
86 [B<-read_buf> I<+int>]
98 [B<-legacy_renegotiation>]
99 [B<-no_renegotiation>]
100 [B<-legacy_server_connect>]
101 [B<-no_resumption_on_reneg>]
102 [B<-no_legacy_server_connect>]
103 [B<-allow_no_dhe_kex>]
104 [B<-prioritize_chacha>]
107 [B<-client_sigalgs> I<val>]
110 [B<-named_curve> I<val>]
112 [B<-ciphersuites> I<val>]
113 [B<-dhparam> I<infile>]
114 [B<-record_padding> I<val>]
115 [B<-debug_broken_protocol>]
118 [B<-verify_name> I<val>]
119 [B<-verify_depth> I<int>]
120 [B<-auth_level> I<int>]
121 [B<-attime> I<intmax>]
122 [B<-verify_hostname> I<val>]
123 [B<-verify_email> I<val>]
125 [B<-ignore_critical>]
130 [B<-explicit_policy>]
139 [B<-suiteB_128_only>]
145 [B<-allow_proxy_certs>]
147 [B<-psk_identity> I<val>]
148 [B<-psk_hint> I<val>]
150 [B<-psk_session> I<file>]
151 [B<-srpvfile> I<infile>]
152 [B<-srpuserseed> I<val>]
167 [B<-nextprotoneg> I<val>]
168 [B<-use_srtp> I<val>]
171 [B<-keylogfile> I<outfile>]
172 [B<-max_early_data> I<int>]
176 [B<-http_server_binmode>]
177 {- $OpenSSL::safe::opt_x_synopsis -}
178 {- $OpenSSL::safe::opt_trust_synopsis -}
179 {- $OpenSSL::safe::opt_r_synopsis -}
181 =for openssl ifdef unix 4 6 unlink no_dhe nextprotoneg use_srtp engine
183 =for openssl ifdef status status_verbose status_timeout status_url status_file
185 =for openssl ifdef psk_hint srpvfile srpuserseed sctp sctp_label_bug
187 =for openssl ifdef sctp sctp_label_bug trace mtu timeout listen
189 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
193 This command implements a generic SSL/TLS server which
194 listens for connections on a given port using SSL/TLS.
198 In addition to the options below, this command also supports
199 the common and server only options documented
200 L<SSL_CONF_cmd(3)/Supported Command Line Commands>
206 Print out a usage message.
208 =item B<-port> I<+int>
210 The TCP port to listen on for connections. If not specified 4433 is used.
212 =item B<-accept> I<val>
214 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
216 =item B<-unix> I<val>
218 Unix domain socket to accept on.
230 For -unix, unlink any existing socket first.
232 =item B<-context> I<val>
234 Sets the SSL context id. It can be given any string value. If this option
235 is not present a default value will be used.
237 =item B<-verify> I<int>, B<-Verify> I<int>
239 The verify depth to use. This specifies the maximum length of the
240 client certificate chain and makes the server request a certificate from
241 the client. With the B<-verify> option a certificate is requested but the
242 client does not have to send one, with the B<-Verify> option the client
243 must supply a certificate or an error occurs.
245 If the cipher suite cannot request a client certificate (for example an
246 anonymous cipher suite or PSK) this option has no effect.
248 =item B<-cert> I<infile>
250 The certificate to use, most servers cipher suites require the use of a
251 certificate and some require a certificate with a certain public key type:
252 for example the DSS cipher suites require a certificate containing a DSS
253 (DSA) key. If not specified then the filename F<server.pem> will be used.
257 A file containing trusted certificates to use when attempting to build the
258 client/server certificate chain related to the certificate specified via the
261 =item B<-build_chain>
263 Specify whether the application should build the certificate chain to be
264 provided to the client.
266 =item B<-nameopt> I<val>
268 Option which determines how the subject or issuer names are displayed. The
269 I<val> argument can be a single option or multiple options separated by
270 commas. Alternatively the B<-nameopt> switch may be used more than once to
271 set multiple options. See the L<openssl-x509(1)> manual page for details.
273 =item B<-naccept> I<+int>
275 The server will exit after receiving the specified number of connections,
278 =item B<-serverinfo> I<val>
280 A file containing one or more blocks of PEM data. Each PEM block
281 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
282 followed by "length" bytes of extension data). If the client sends
283 an empty TLS ClientHello extension matching the type, the corresponding
284 ServerHello extension will be returned.
286 =item B<-certform> B<DER>|B<PEM>, B<-CRLForm> B<DER>|B<PEM>
288 The certificate and CRL format; the default is PEM.
289 See L<openssl(1)/Format Options> for details.
291 =item B<-key> I<infile>
293 The private key to use. If not specified then the certificate file will
296 =item B<-keyform> B<DER>|B<PEM>
298 The key format; the default is B<PEM>.
299 See L<openssl(1)/Format Options> for details.
301 =item B<-pass> I<val>
303 The private key password source.
304 For more information about the format of I<val>,
305 see L<openssl(1)/Pass Phrase Options>.
307 =item B<-dcert> I<infile>, B<-dkey> I<infile>
309 Specify an additional certificate and private key, these behave in the
310 same manner as the B<-cert> and B<-key> options except there is no default
311 if they are not specified (no additional certificate and key is used). As
312 noted above some cipher suites require a certificate containing a key of
313 a certain type. Some cipher suites need a certificate carrying an RSA key
314 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
315 a server can support clients which only support RSA or DSS cipher suites
316 by using an appropriate certificate.
318 =item B<-dcert_chain>
320 A file containing trusted certificates to use when attempting to build the
321 server certificate chain when a certificate specified via the B<-dcert> option
324 =item B<-dcertform> B<DER>|B<PEM>, B<-dkeyform> B<DER>|B<PEM>
326 The format of the certificate and private key; the default is B<PEM>
327 see L<openssl(1)/Format Options>.
329 =item B<-dpass> I<val>
331 The passphrase for the additional private key.
332 For more information about the format of I<val>,
333 see L<openssl(1)/Pass Phrase Options>.
337 Tests non blocking I/O.
341 This option translated a line feed from the terminal into CR+LF.
345 Print extensive debugging information including a hex dump of all traffic.
349 Show all protocol messages with hex dump.
351 =item B<-msgfile> I<outfile>
353 File to send output of B<-msg> or B<-trace> to, default standard output.
357 Prints the SSL session states.
359 =item B<-chainCApath> I<dir>
361 The directory to use for building the chain provided to the client. This
362 directory must be in "hash format", see L<openssl-verify(1)> for more
365 =item B<-chainCAfile> I<file>
367 A file containing trusted certificates to use when attempting to build the
368 server certificate chain.
370 =item B<-chainCAstore> I<uri>
372 The URI to a store to use for building the chain provided to the client.
373 The URI may indicate a single certificate, as well as a collection of
375 With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
376 B<-chainCApath>, depending on if the URI indicates a directory or a
378 See L<ossl_store-file(7)> for more information on the C<file:> scheme.
382 If this option is set then no certificate is used. This restricts the
383 cipher suites available to the anonymous ones (currently just anonymous
388 Inhibit printing of session and certificate information.
392 Sends a status message back to the client when it connects. This includes
393 information about the ciphers used and various session parameters.
394 The output is in HTML format so this option will normally be used with a
395 web browser. Cannot be used in conjunction with B<-early_data>.
399 Emulates a simple web server. Pages will be resolved relative to the
400 current directory, for example if the URL https://myhost/page.html is
401 requested the file F<./page.html> will be loaded. Cannot be used in conjunction
404 =item B<-tlsextdebug>
406 Print a hex dump of any TLS extensions received from the server.
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 F<./page.html> will be loaded. The files loaded are
413 assumed to contain a complete and correct HTTP response (lines that
414 are part of the HTTP response line and headers must end with CRLF). Cannot be
415 used in conjunction with B<-early_data>.
417 =item B<-id_prefix> I<val>
419 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
420 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
421 servers, when each of which might be generating a unique range of session
422 IDs (eg. with a certain prefix).
424 =item B<-verify_return_error>
426 Verification errors normally just print a message but allow the
427 connection to continue, for debugging purposes.
428 If this option is used, then verification errors close the connection.
432 Enables certificate status request support (aka OCSP stapling).
434 =item B<-status_verbose>
436 Enables certificate status request support (aka OCSP stapling) and gives
437 a verbose printout of the OCSP response.
439 =item B<-status_timeout> I<int>
441 Sets the timeout for OCSP response to I<int> seconds.
443 =item B<-status_url> I<val>
445 Sets a fallback responder URL to use if no responder URL is present in the
446 server certificate. Without this option an error is returned if the server
447 certificate does not contain a responder address.
449 =item B<-status_file> I<infile>
451 Overrides any OCSP responder URLs from the certificate and always provides the
452 OCSP Response stored in the file. The file must be in DER format.
456 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
457 with B<enable-ssl-trace> for this option to work.
461 Provide a brief summary of connection parameters instead of the normal verbose
466 Simple test server which just reverses the text received from the client
467 and sends it back to the server. Also sets B<-brief>. Cannot be used in
468 conjunction with B<-early_data>.
472 Switch on asynchronous mode. Cryptographic operations will be performed
473 asynchronously. This will only have an effect if an asynchronous capable engine
474 is also used via the B<-engine> option. For test purposes the dummy async engine
475 (dasync) can be used (if available).
477 =item B<-max_send_frag> I<+int>
479 The maximum size of data fragment to send.
480 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
482 =item B<-split_send_frag> I<+int>
484 The size used to split data for encrypt pipelines. If more data is written in
485 one go than this value then it will be split into multiple pipelines, up to the
486 maximum number of pipelines defined by max_pipelines. This only has an effect if
487 a suitable cipher suite has been negotiated, an engine that supports pipelining
488 has been loaded, and max_pipelines is greater than 1. See
489 L<SSL_CTX_set_split_send_fragment(3)> for further information.
491 =item B<-max_pipelines> I<+int>
493 The maximum number of encrypt/decrypt pipelines to be used. This will only have
494 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
495 engine) and a suitable cipher suite has been negotiated. The default value is 1.
496 See L<SSL_CTX_set_max_pipelines(3)> for further information.
498 =item B<-read_buf> I<+int>
500 The default read buffer size to be used for connections. This will only have an
501 effect if the buffer size is larger than the size that would otherwise be used
502 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
503 further information).
505 =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>
507 These options require or disable the use of the specified SSL or TLS protocols.
508 By default, this command will negotiate the highest mutually supported
510 When a specific TLS version is required, only that version will be accepted
512 Note that not all protocols and flags may be available, depending on how
517 There are several known bugs in SSL and TLS implementations. Adding this
518 option enables various workarounds.
522 Disable negotiation of TLS compression.
523 TLS compression is not recommended and is off by default as of
528 Enable negotiation of TLS compression.
529 This option was introduced in OpenSSL 1.1.0.
530 TLS compression is not recommended and is off by default as of
535 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
536 is negotiated. See B<-num_tickets>.
538 =item B<-num_tickets>
540 Control the number of tickets that will be sent to the client after a full
541 handshake in TLSv1.3. The default number of tickets is 2. This option does not
542 affect the number of tickets sent after a resumption handshake.
546 Use the server's cipher preferences, rather than the client's preferences.
548 =item B<-prioritize_chacha>
550 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
552 =item B<-no_resumption_on_reneg>
554 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
556 =item B<-client_sigalgs> I<val>
558 Signature algorithms to support for client certificate authentication
559 (colon-separated list).
561 =item B<-named_curve> I<val>
563 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
564 For a list of all possible curves, use:
566 $ openssl ecparam -list_curves
568 =item B<-cipher> I<val>
570 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
571 modified. This list is combined with any TLSv1.3 ciphersuites that have been
572 configured. When the client sends a list of supported ciphers the first client
573 cipher also included in the server list is used. Because the client specifies
574 the preference order, the order of the server cipherlist is irrelevant. See
575 L<openssl-ciphers(1)> for more information.
577 =item B<-ciphersuites> I<val>
579 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
580 This list is combined with any TLSv1.2 and below ciphersuites that have been
581 configured. When the client sends a list of supported ciphers the first client
582 cipher also included in the server list is used. Because the client specifies
583 the preference order, the order of the server cipherlist is irrelevant. See
584 L<openssl-ciphers(1)> command for more information. The format for this list is
585 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
587 =item B<-dhparam> I<infile>
589 The DH parameter file to use. The ephemeral DH cipher suites generate keys
590 using a set of DH parameters. If not specified then an attempt is made to
591 load the parameters from the server certificate file.
592 If this fails then a static set of parameters hard coded into this command
595 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
596 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
597 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
598 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
599 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
600 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
601 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
603 Set different peer certificate verification options.
604 See the L<openssl-verify(1)> manual page for details.
606 =item B<-crl_check>, B<-crl_check_all>
608 Check the peer certificate has not been revoked by its CA.
609 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
610 option all CRLs of all CAs in the chain are checked.
614 Turns on non blocking I/O.
616 =item B<-psk_identity> I<val>
618 Expect the client to send PSK identity I<val> when using a PSK
619 cipher suite, and warn if they do not. By default, the expected PSK
620 identity is the string "Client_identity".
622 =item B<-psk_hint> I<val>
624 Use the PSK identity hint I<val> when using a PSK cipher suite.
628 Use the PSK key I<val> when using a PSK cipher suite. The key is
629 given as a hexadecimal number without leading 0x, for example -psk
631 This option must be provided in order to use a PSK cipher.
633 =item B<-psk_session> I<file>
635 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
636 Note that this will only work if TLSv1.3 is negotiated.
640 This option can only be used in conjunction with one of the DTLS options above.
641 With this option, this command will listen on a UDP port for incoming
643 Any ClientHellos that arrive will be checked to see if they have a cookie in
645 Any without a cookie will be responded to with a HelloVerifyRequest.
646 If a ClientHello with a cookie is received then this command will
647 connect to that peer and complete the handshake.
649 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
651 These options make this command use DTLS protocols instead of TLS.
652 With B<-dtls>, it will negotiate any supported DTLS protocol
653 version, whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and
654 DTLSv1.2 respectively.
658 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
659 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
660 available where OpenSSL has support for SCTP enabled.
662 =item B<-sctp_label_bug>
664 Use the incorrect behaviour of older OpenSSL implementations when computing
665 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
666 older broken implementations but breaks interoperability with correct
667 implementations. Must be used in conjunction with B<-sctp>. This option is only
668 available where OpenSSL has support for SCTP enabled.
672 If this option is set then no DH parameters will be loaded effectively
673 disabling the ephemeral DH cipher suites.
675 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
677 These flags enable the Enable the Application-Layer Protocol Negotiation
678 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
679 IETF standard and replaces NPN.
680 The I<val> list is a comma-separated list of supported protocol
681 names. The list should contain the most desirable protocols first.
682 Protocol names are printable ASCII strings, for example "http/1.1" or
684 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
686 =item B<-engine> I<val>
688 Specifying an engine (by its unique id string in I<val>) will cause
689 this command to attempt to obtain a functional reference to the
690 specified engine, thus initialising it if needed. The engine will then be
691 set as the default for all available algorithms.
693 =item B<-keylogfile> I<outfile>
695 Appends TLS secrets to the specified keylog file such that external programs
696 (like Wireshark) can decrypt TLS connections.
698 =item B<-max_early_data> I<int>
700 Change the default maximum early data bytes that are specified for new sessions
701 and any incoming early data (when used in conjunction with the B<-early_data>
702 flag). The default value is approximately 16k. The argument must be an integer
703 greater than or equal to 0.
707 Accept early data where possible. Cannot be used in conjunction with B<-www>,
708 B<-WWW>, B<-HTTP> or B<-rev>.
710 =item B<-anti_replay>, B<-no_anti_replay>
712 Switches replay protection on or off, respectively. Replay protection is on by
713 default unless overridden by a configuration file. When it is on, OpenSSL will
714 automatically detect if a session ticket has been used more than once, TLSv1.3
715 has been negotiated, and early data is enabled on the server. A full handshake
716 is forced if a session ticket is used a second or subsequent time. Any early
717 data that was sent will be rejected.
719 =item B<-http_server_binmode>
721 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
722 by the client in binary mode.
724 {- $OpenSSL::safe::opt_x_item -}
726 {- $OpenSSL::safe::opt_trust_item -}
728 {- $OpenSSL::safe::opt_r_item -}
732 =head1 CONNECTED COMMANDS
734 If a connection request is established with an SSL client and neither the
735 B<-www> nor the B<-WWW> option has been used then normally any data received
736 from the client is displayed and any key presses will be sent to the client.
738 Certain commands are also recognized which perform special operations. These
739 commands are a letter which must appear at the start of a line. They are listed
746 End the current SSL connection but still accept new connections.
750 End the current SSL connection and exit.
754 Renegotiate the SSL session (TLSv1.2 and below only).
758 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
763 Send some plain text down the underlying TCP connection: this should
764 cause the client to disconnect due to a protocol violation.
768 Print out some session cache status information.
772 Send a key update message to the client (TLSv1.3 only)
776 Send a key update message to the client and request one back (TLSv1.3 only)
780 Send a certificate request to the client (TLSv1.3 only)
786 This command can be used to debug SSL clients. To accept connections
787 from a web browser the command:
789 openssl s_server -accept 443 -www
791 can be used for example.
793 Although specifying an empty list of CAs when requesting a client certificate
794 is strictly speaking a protocol violation, some SSL clients interpret this to
795 mean any CA is acceptable. This is useful for debugging purposes.
797 The session parameters can printed out using the L<openssl-sess_id(1)> command.
801 Because this program has a lot of options and also because some of the
802 techniques used are rather old, the C source for this command is rather
803 hard to read and not a model of how things should be done.
804 A typical SSL server program would be much simpler.
806 The output of common ciphers is wrong: it just gives the list of ciphers that
807 OpenSSL recognizes and the client supports.
809 There should be a way for this command to print out details
810 of any unknown cipher suites a client says it supports.
815 L<openssl-sess_id(1)>,
816 L<openssl-s_client(1)>,
817 L<openssl-ciphers(1)>,
819 L<SSL_CTX_set_max_send_fragment(3)>,
820 L<SSL_CTX_set_split_send_fragment(3)>,
821 L<SSL_CTX_set_max_pipelines(3)>,
822 L<ossl_store-file(7)>
826 The -no_alt_chains option was added in OpenSSL 1.1.0.
829 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
833 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
835 Licensed under the Apache License 2.0 (the "License"). You may not use
836 this file except in compliance with the License. You can obtain a copy
837 in the file LICENSE in the source distribution or at
838 L<https://www.openssl.org/source/license.html>.