2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-s_server - SSL/TLS server program
10 B<openssl> B<s_server>
23 [B<-serverinfo> I<val>]
24 [B<-certform> B<DER>|B<PEM>]
26 [B<-keyform> B<DER>|B<PEM>]
29 [B<-dcertform> B<DER>|B<PEM>]
31 [B<-dkeyform> B<DER>|B<PEM>]
37 [B<-msgfile> I<outfile>]
41 [B<-no_resume_ephemeral>]
45 [B<-servername_fatal>]
50 [B<-id_prefix> I<val>]
51 [B<-keymatexport> I<val>]
52 [B<-keymatexportlen> I<+int>]
55 [B<-cert_chain> I<infile>]
56 [B<-dcert_chain> I<infile>]
57 [B<-chainCApath> I<dir>]
58 [B<-verifyCApath> I<dir>]
59 [B<-chainCAstore> I<uri>]
60 [B<-verifyCAstore> I<uri>]
63 [B<-verify_return_error>]
66 [B<-chainCAfile> I<infile>]
67 [B<-verifyCAfile> I<infile>]
72 [B<-status_timeout> I<int>]
73 [B<-status_url> I<val>]
74 [B<-status_file> I<infile>]
77 [B<-security_debug_verbose>]
81 [B<-ssl_config> I<val>]
82 [B<-max_send_frag> I<+int>]
83 [B<-split_send_frag> I<+int>]
84 [B<-max_pipelines> I<+int>]
85 [B<-read_buf> I<+int>]
97 [B<-legacy_renegotiation>]
98 [B<-no_renegotiation>]
99 [B<-legacy_server_connect>]
100 [B<-no_resumption_on_reneg>]
101 [B<-no_legacy_server_connect>]
102 [B<-allow_no_dhe_kex>]
103 [B<-prioritize_chacha>]
106 [B<-client_sigalgs> I<val>]
109 [B<-named_curve> I<val>]
111 [B<-ciphersuites> I<val>]
112 [B<-dhparam> I<infile>]
113 [B<-record_padding> I<val>]
114 [B<-debug_broken_protocol>]
117 [B<-verify_name> I<val>]
118 [B<-verify_depth> I<int>]
119 [B<-auth_level> I<int>]
120 [B<-attime> I<intmax>]
121 [B<-verify_hostname> I<val>]
122 [B<-verify_email> I<val>]
124 [B<-ignore_critical>]
129 [B<-explicit_policy>]
138 [B<-suiteB_128_only>]
144 [B<-allow_proxy_certs>]
146 [B<-psk_identity> I<val>]
147 [B<-psk_hint> I<val>]
149 [B<-psk_session> I<file>]
150 [B<-srpvfile> I<infile>]
151 [B<-srpuserseed> I<val>]
166 [B<-nextprotoneg> I<val>]
167 [B<-use_srtp> I<val>]
169 [B<-keylogfile> I<outfile>]
170 [B<-max_early_data> I<int>]
174 [B<-http_server_binmode>]
175 {- $OpenSSL::safe::opt_name_synopsis -}
176 {- $OpenSSL::safe::opt_x_synopsis -}
177 {- $OpenSSL::safe::opt_trust_synopsis -}
178 {- $OpenSSL::safe::opt_r_synopsis -}
179 {- $OpenSSL::safe::opt_engine_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<-naccept> I<+int>
268 The server will exit after receiving the specified number of connections,
271 =item B<-serverinfo> I<val>
273 A file containing one or more blocks of PEM data. Each PEM block
274 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
275 followed by "length" bytes of extension data). If the client sends
276 an empty TLS ClientHello extension matching the type, the corresponding
277 ServerHello extension will be returned.
279 =item B<-certform> B<DER>|B<PEM>, B<-CRLForm> B<DER>|B<PEM>
281 The certificate and CRL format; the default is PEM.
282 See L<openssl(1)/Format Options> for details.
284 =item B<-key> I<infile>
286 The private key to use. If not specified then the certificate file will
289 =item B<-keyform> B<DER>|B<PEM>
291 The key format; the default is B<PEM>.
292 See L<openssl(1)/Format Options> for details.
294 =item B<-pass> I<val>
296 The private key password source.
297 For more information about the format of I<val>,
298 see L<openssl(1)/Pass Phrase Options>.
300 =item B<-dcert> I<infile>, B<-dkey> I<infile>
302 Specify an additional certificate and private key, these behave in the
303 same manner as the B<-cert> and B<-key> options except there is no default
304 if they are not specified (no additional certificate and key is used). As
305 noted above some cipher suites require a certificate containing a key of
306 a certain type. Some cipher suites need a certificate carrying an RSA key
307 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
308 a server can support clients which only support RSA or DSS cipher suites
309 by using an appropriate certificate.
311 =item B<-dcert_chain>
313 A file containing trusted certificates to use when attempting to build the
314 server certificate chain when a certificate specified via the B<-dcert> option
317 =item B<-dcertform> B<DER>|B<PEM>, B<-dkeyform> B<DER>|B<PEM>
319 The format of the certificate and private key; the default is B<PEM>
320 see L<openssl(1)/Format Options>.
322 =item B<-dpass> I<val>
324 The passphrase for the additional private key.
325 For more information about the format of I<val>,
326 see L<openssl(1)/Pass Phrase Options>.
330 Tests non blocking I/O.
334 This option translated a line feed from the terminal into CR+LF.
338 Print extensive debugging information including a hex dump of all traffic.
342 Show all protocol messages with hex dump.
344 =item B<-msgfile> I<outfile>
346 File to send output of B<-msg> or B<-trace> to, default standard output.
350 Prints the SSL session states.
352 =item B<-chainCApath> I<dir>
354 The directory to use for building the chain provided to the client. This
355 directory must be in "hash format", see L<openssl-verify(1)> for more
358 =item B<-chainCAfile> I<file>
360 A file containing trusted certificates to use when attempting to build the
361 server certificate chain.
363 =item B<-chainCAstore> I<uri>
365 The URI to a store to use for building the chain provided to the client.
366 The URI may indicate a single certificate, as well as a collection of
368 With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
369 B<-chainCApath>, depending on if the URI indicates a directory or a
371 See L<ossl_store-file(7)> for more information on the C<file:> scheme.
375 If this option is set then no certificate is used. This restricts the
376 cipher suites available to the anonymous ones (currently just anonymous
381 Inhibit printing of session and certificate information.
385 Sends a status message back to the client when it connects. This includes
386 information about the ciphers used and various session parameters.
387 The output is in HTML format so this option will normally be used with a
388 web browser. Cannot be used in conjunction with B<-early_data>.
392 Emulates a simple web server. Pages will be resolved relative to the
393 current directory, for example if the URL https://myhost/page.html is
394 requested the file F<./page.html> will be loaded. Cannot be used in conjunction
397 =item B<-tlsextdebug>
399 Print a hex dump of any TLS extensions received from the server.
403 Emulates a simple web server. Pages will be resolved relative to the
404 current directory, for example if the URL https://myhost/page.html is
405 requested the file F<./page.html> will be loaded. The files loaded are
406 assumed to contain a complete and correct HTTP response (lines that
407 are part of the HTTP response line and headers must end with CRLF). Cannot be
408 used in conjunction with B<-early_data>.
410 =item B<-id_prefix> I<val>
412 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
413 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
414 servers, when each of which might be generating a unique range of session
415 IDs (eg. with a certain prefix).
417 =item B<-verify_return_error>
419 Verification errors normally just print a message but allow the
420 connection to continue, for debugging purposes.
421 If this option is used, then verification errors close the connection.
425 Enables certificate status request support (aka OCSP stapling).
427 =item B<-status_verbose>
429 Enables certificate status request support (aka OCSP stapling) and gives
430 a verbose printout of the OCSP response.
432 =item B<-status_timeout> I<int>
434 Sets the timeout for OCSP response to I<int> seconds.
436 =item B<-status_url> I<val>
438 Sets a fallback responder URL to use if no responder URL is present in the
439 server certificate. Without this option an error is returned if the server
440 certificate does not contain a responder address.
442 =item B<-status_file> I<infile>
444 Overrides any OCSP responder URLs from the certificate and always provides the
445 OCSP Response stored in the file. The file must be in DER format.
449 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
450 with B<enable-ssl-trace> for this option to work.
454 Provide a brief summary of connection parameters instead of the normal verbose
459 Simple test server which just reverses the text received from the client
460 and sends it back to the server. Also sets B<-brief>. Cannot be used in
461 conjunction with B<-early_data>.
465 Switch on asynchronous mode. Cryptographic operations will be performed
466 asynchronously. This will only have an effect if an asynchronous capable engine
467 is also used via the B<-engine> option. For test purposes the dummy async engine
468 (dasync) can be used (if available).
470 =item B<-max_send_frag> I<+int>
472 The maximum size of data fragment to send.
473 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
475 =item B<-split_send_frag> I<+int>
477 The size used to split data for encrypt pipelines. If more data is written in
478 one go than this value then it will be split into multiple pipelines, up to the
479 maximum number of pipelines defined by max_pipelines. This only has an effect if
480 a suitable cipher suite has been negotiated, an engine that supports pipelining
481 has been loaded, and max_pipelines is greater than 1. See
482 L<SSL_CTX_set_split_send_fragment(3)> for further information.
484 =item B<-max_pipelines> I<+int>
486 The maximum number of encrypt/decrypt pipelines to be used. This will only have
487 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
488 engine) and a suitable cipher suite has been negotiated. The default value is 1.
489 See L<SSL_CTX_set_max_pipelines(3)> for further information.
491 =item B<-read_buf> I<+int>
493 The default read buffer size to be used for connections. This will only have an
494 effect if the buffer size is larger than the size that would otherwise be used
495 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
496 further information).
498 =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>
500 These options require or disable the use of the specified SSL or TLS protocols.
501 By default, this command will negotiate the highest mutually supported
503 When a specific TLS version is required, only that version will be accepted
505 Note that not all protocols and flags may be available, depending on how
510 There are several known bugs in SSL and TLS implementations. Adding this
511 option enables various workarounds.
515 Disable negotiation of TLS compression.
516 TLS compression is not recommended and is off by default as of
521 Enable negotiation of TLS compression.
522 This option was introduced in OpenSSL 1.1.0.
523 TLS compression is not recommended and is off by default as of
528 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
529 is negotiated. See B<-num_tickets>.
531 =item B<-num_tickets>
533 Control the number of tickets that will be sent to the client after a full
534 handshake in TLSv1.3. The default number of tickets is 2. This option does not
535 affect the number of tickets sent after a resumption handshake.
539 Use the server's cipher preferences, rather than the client's preferences.
541 =item B<-prioritize_chacha>
543 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
545 =item B<-no_resumption_on_reneg>
547 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
549 =item B<-client_sigalgs> I<val>
551 Signature algorithms to support for client certificate authentication
552 (colon-separated list).
554 =item B<-named_curve> I<val>
556 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
557 For a list of all possible curves, use:
559 $ openssl ecparam -list_curves
561 =item B<-cipher> I<val>
563 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
564 modified. This list is combined with any TLSv1.3 ciphersuites that have been
565 configured. When the client sends a list of supported ciphers the first client
566 cipher also included in the server list is used. Because the client specifies
567 the preference order, the order of the server cipherlist is irrelevant. See
568 L<openssl-ciphers(1)> for more information.
570 =item B<-ciphersuites> I<val>
572 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
573 This list is combined with any TLSv1.2 and below ciphersuites that have been
574 configured. When the client sends a list of supported ciphers the first client
575 cipher also included in the server list is used. Because the client specifies
576 the preference order, the order of the server cipherlist is irrelevant. See
577 L<openssl-ciphers(1)> command for more information. The format for this list is
578 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
580 =item B<-dhparam> I<infile>
582 The DH parameter file to use. The ephemeral DH cipher suites generate keys
583 using a set of DH parameters. If not specified then an attempt is made to
584 load the parameters from the server certificate file.
585 If this fails then a static set of parameters hard coded into this command
588 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
589 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
590 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
591 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
592 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
593 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
594 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
596 Set different peer certificate verification options.
597 See the L<openssl-verify(1)> manual page for details.
599 =item B<-crl_check>, B<-crl_check_all>
601 Check the peer certificate has not been revoked by its CA.
602 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
603 option all CRLs of all CAs in the chain are checked.
607 Turns on non blocking I/O.
609 =item B<-psk_identity> I<val>
611 Expect the client to send PSK identity I<val> when using a PSK
612 cipher suite, and warn if they do not. By default, the expected PSK
613 identity is the string "Client_identity".
615 =item B<-psk_hint> I<val>
617 Use the PSK identity hint I<val> when using a PSK cipher suite.
621 Use the PSK key I<val> when using a PSK cipher suite. The key is
622 given as a hexadecimal number without leading 0x, for example -psk
624 This option must be provided in order to use a PSK cipher.
626 =item B<-psk_session> I<file>
628 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
629 Note that this will only work if TLSv1.3 is negotiated.
633 This option can only be used in conjunction with one of the DTLS options above.
634 With this option, this command will listen on a UDP port for incoming
636 Any ClientHellos that arrive will be checked to see if they have a cookie in
638 Any without a cookie will be responded to with a HelloVerifyRequest.
639 If a ClientHello with a cookie is received then this command will
640 connect to that peer and complete the handshake.
642 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
644 These options make this command use DTLS protocols instead of TLS.
645 With B<-dtls>, it will negotiate any supported DTLS protocol
646 version, whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and
647 DTLSv1.2 respectively.
651 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
652 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
653 available where OpenSSL has support for SCTP enabled.
655 =item B<-sctp_label_bug>
657 Use the incorrect behaviour of older OpenSSL implementations when computing
658 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
659 older broken implementations but breaks interoperability with correct
660 implementations. Must be used in conjunction with B<-sctp>. This option is only
661 available where OpenSSL has support for SCTP enabled.
665 If this option is set then no DH parameters will be loaded effectively
666 disabling the ephemeral DH cipher suites.
668 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
670 These flags enable the Enable the Application-Layer Protocol Negotiation
671 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
672 IETF standard and replaces NPN.
673 The I<val> list is a comma-separated list of supported protocol
674 names. The list should contain the most desirable protocols first.
675 Protocol names are printable ASCII strings, for example "http/1.1" or
677 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
679 =item B<-keylogfile> I<outfile>
681 Appends TLS secrets to the specified keylog file such that external programs
682 (like Wireshark) can decrypt TLS connections.
684 =item B<-max_early_data> I<int>
686 Change the default maximum early data bytes that are specified for new sessions
687 and any incoming early data (when used in conjunction with the B<-early_data>
688 flag). The default value is approximately 16k. The argument must be an integer
689 greater than or equal to 0.
693 Accept early data where possible. Cannot be used in conjunction with B<-www>,
694 B<-WWW>, B<-HTTP> or B<-rev>.
696 =item B<-anti_replay>, B<-no_anti_replay>
698 Switches replay protection on or off, respectively. Replay protection is on by
699 default unless overridden by a configuration file. When it is on, OpenSSL will
700 automatically detect if a session ticket has been used more than once, TLSv1.3
701 has been negotiated, and early data is enabled on the server. A full handshake
702 is forced if a session ticket is used a second or subsequent time. Any early
703 data that was sent will be rejected.
705 =item B<-http_server_binmode>
707 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
708 by the client in binary mode.
710 {- $OpenSSL::safe::opt_name_item -}
712 {- $OpenSSL::safe::opt_x_item -}
714 {- $OpenSSL::safe::opt_trust_item -}
716 {- $OpenSSL::safe::opt_r_item -}
718 {- $OpenSSL::safe::opt_engine_item -}
722 =head1 CONNECTED COMMANDS
724 If a connection request is established with an SSL client and neither the
725 B<-www> nor the B<-WWW> option has been used then normally any data received
726 from the client is displayed and any key presses will be sent to the client.
728 Certain commands are also recognized which perform special operations. These
729 commands are a letter which must appear at the start of a line. They are listed
736 End the current SSL connection but still accept new connections.
740 End the current SSL connection and exit.
744 Renegotiate the SSL session (TLSv1.2 and below only).
748 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
753 Send some plain text down the underlying TCP connection: this should
754 cause the client to disconnect due to a protocol violation.
758 Print out some session cache status information.
762 Send a key update message to the client (TLSv1.3 only)
766 Send a key update message to the client and request one back (TLSv1.3 only)
770 Send a certificate request to the client (TLSv1.3 only)
776 This command can be used to debug SSL clients. To accept connections
777 from a web browser the command:
779 openssl s_server -accept 443 -www
781 can be used for example.
783 Although specifying an empty list of CAs when requesting a client certificate
784 is strictly speaking a protocol violation, some SSL clients interpret this to
785 mean any CA is acceptable. This is useful for debugging purposes.
787 The session parameters can printed out using the L<openssl-sess_id(1)> command.
791 Because this program has a lot of options and also because some of the
792 techniques used are rather old, the C source for this command is rather
793 hard to read and not a model of how things should be done.
794 A typical SSL server program would be much simpler.
796 The output of common ciphers is wrong: it just gives the list of ciphers that
797 OpenSSL recognizes and the client supports.
799 There should be a way for this command to print out details
800 of any unknown cipher suites a client says it supports.
805 L<openssl-sess_id(1)>,
806 L<openssl-s_client(1)>,
807 L<openssl-ciphers(1)>,
809 L<SSL_CTX_set_max_send_fragment(3)>,
810 L<SSL_CTX_set_split_send_fragment(3)>,
811 L<SSL_CTX_set_max_pipelines(3)>,
812 L<ossl_store-file(7)>
816 The -no_alt_chains option was added in OpenSSL 1.1.0.
819 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
823 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
825 Licensed under the Apache License 2.0 (the "License"). You may not use
826 this file except in compliance with the License. You can obtain a copy
827 in the file LICENSE in the source distribution or at
828 L<https://www.openssl.org/source/license.html>.