2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-s_server - SSL/TLS server program
10 B<openssl> B<s_server>
23 [B<-certform> B<DER>|B<PEM>|B<P12>]
24 [B<-cert_chain> I<infile>]
26 [B<-serverinfo> I<val>]
29 [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
32 [B<-dcertform> B<DER>|B<PEM>|B<P12>]
33 [B<-dcert_chain> I<infile>]
35 [B<-dkeyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
41 [B<-msgfile> I<outfile>]
45 [B<-no_resume_ephemeral>]
48 [B<-http_server_binmode>]
50 [B<-ignore_unexpected_eof>]
52 [B<-servername_fatal>]
55 [B<-id_prefix> I<val>]
56 [B<-keymatexport> I<val>]
57 [B<-keymatexportlen> I<+int>]
59 [B<-CRLform> B<DER>|B<PEM>]
61 [B<-chainCAfile> I<infile>]
62 [B<-chainCApath> I<dir>]
63 [B<-chainCAstore> I<uri>]
64 [B<-verifyCAfile> I<infile>]
65 [B<-verifyCApath> I<dir>]
66 [B<-verifyCAstore> I<uri>]
69 [B<-verify_return_error>]
75 [B<-status_timeout> I<int>]
76 [B<-status_url> I<val>]
77 [B<-status_file> I<infile>]
80 [B<-security_debug_verbose>]
84 [B<-ssl_config> I<val>]
85 [B<-max_send_frag> I<+int>]
86 [B<-split_send_frag> I<+int>]
87 [B<-max_pipelines> I<+int>]
89 [B<-read_buf> I<+int>]
95 [B<-legacy_renegotiation>]
96 [B<-no_renegotiation>]
97 [B<-legacy_server_connect>]
98 [B<-no_resumption_on_reneg>]
99 [B<-no_legacy_server_connect>]
100 [B<-allow_no_dhe_kex>]
101 [B<-prioritize_chacha>]
104 [B<-client_sigalgs> I<val>]
107 [B<-named_curve> I<val>]
109 [B<-ciphersuites> I<val>]
110 [B<-dhparam> I<infile>]
111 [B<-record_padding> I<val>]
112 [B<-debug_broken_protocol>]
114 [B<-psk_identity> I<val>]
115 [B<-psk_hint> I<val>]
117 [B<-psk_session> I<file>]
118 [B<-srpvfile> I<infile>]
119 [B<-srpuserseed> I<val>]
126 [B<-nextprotoneg> I<val>]
127 [B<-use_srtp> I<val>]
130 [B<-keylogfile> I<outfile>]
131 [B<-recv_max_early_data> I<int>]
132 [B<-max_early_data> I<int>]
138 {- $OpenSSL::safe::opt_name_synopsis -}
139 {- $OpenSSL::safe::opt_version_synopsis -}
140 {- $OpenSSL::safe::opt_v_synopsis -}
141 {- $OpenSSL::safe::opt_s_synopsis -}
142 {- $OpenSSL::safe::opt_x_synopsis -}
143 {- $OpenSSL::safe::opt_trust_synopsis -}
144 {- $OpenSSL::safe::opt_r_synopsis -}
145 {- $OpenSSL::safe::opt_engine_synopsis -}
146 {- $OpenSSL::safe::opt_provider_synopsis -}
148 =for openssl ifdef unix 4 6 unlink no_dhe nextprotoneg use_srtp engine
150 =for openssl ifdef status status_verbose status_timeout status_url status_file
152 =for openssl ifdef psk_hint srpvfile srpuserseed sctp sctp_label_bug
154 =for openssl ifdef sctp sctp_label_bug trace mtu timeout listen
156 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
158 =for openssl ifdef sendfile
162 This command implements a generic SSL/TLS server which
163 listens for connections on a given port using SSL/TLS.
167 In addition to the options below, this command also supports
168 the common and server only options documented
169 L<SSL_CONF_cmd(3)/Supported Command Line Commands>
175 Print out a usage message.
177 =item B<-port> I<+int>
179 The TCP port to listen on for connections. If not specified 4433 is used.
181 =item B<-accept> I<val>
183 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
185 =item B<-unix> I<val>
187 Unix domain socket to accept on.
199 For -unix, unlink any existing socket first.
201 =item B<-context> I<val>
203 Sets the SSL context id. It can be given any string value. If this option
204 is not present a default value will be used.
206 =item B<-verify> I<int>, B<-Verify> I<int>
208 The verify depth to use. This specifies the maximum length of the
209 client certificate chain and makes the server request a certificate from
210 the client. With the B<-verify> option a certificate is requested but the
211 client does not have to send one, with the B<-Verify> option the client
212 must supply a certificate or an error occurs.
214 If the cipher suite cannot request a client certificate (for example an
215 anonymous cipher suite or PSK) this option has no effect.
217 =item B<-cert> I<infile>
219 The certificate to use, most servers cipher suites require the use of a
220 certificate and some require a certificate with a certain public key type:
221 for example the DSS cipher suites require a certificate containing a DSS
222 (DSA) key. If not specified then the filename F<server.pem> will be used.
224 =item B<-certform> B<DER>|B<PEM>|B<P12>
226 The server certificate file format.
227 This option has no effect and is retained for backward compatibility only.
231 A file containing untrusted certificates to use when attempting to build the
232 certificate chain related to the certificate specified via the B<-cert> option.
234 =item B<-build_chain>
236 Specify whether the application should build the server certificate chain to be
237 provided to the client.
239 =item B<-serverinfo> I<val>
241 A file containing one or more blocks of PEM data. Each PEM block
242 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
243 followed by "length" bytes of extension data). If the client sends
244 an empty TLS ClientHello extension matching the type, the corresponding
245 ServerHello extension will be returned.
247 =item B<-key> I<infile>
249 The private key to use. If not specified then the certificate file will
252 =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
254 The key format; the default is B<PEM>.
255 The only value with effect is B<ENGINE>; all others have become obsolete.
256 See L<openssl(1)/Format Options> for details.
258 =item B<-pass> I<val>
260 The private key password source.
261 For more information about the format of I<val>,
262 see L<openssl(1)/Pass Phrase Options>.
264 =item B<-dcert> I<infile>, B<-dkey> I<infile>
266 Specify an additional certificate and private key, these behave in the
267 same manner as the B<-cert> and B<-key> options except there is no default
268 if they are not specified (no additional certificate and key is used). As
269 noted above some cipher suites require a certificate containing a key of
270 a certain type. Some cipher suites need a certificate carrying an RSA key
271 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
272 a server can support clients which only support RSA or DSS cipher suites
273 by using an appropriate certificate.
275 =item B<-dcert_chain>
277 A file containing untrusted certificates to use when attempting to build the
278 server certificate chain when a certificate specified via the B<-dcert> option
281 =item B<-dcertform> B<DER>|B<PEM>|B<P12>
283 The format of the additional certificate file.
284 This option has no effect and is retained for backward compatibility only.
286 =item B<-dkeyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
288 The format of the additional private key; the default is B<PEM>.
289 The only value with effect is B<ENGINE>; all others have become obsolete.
290 See L<openssl(1)/Format Options>.
292 =item B<-dpass> I<val>
294 The passphrase for the additional private key.
295 For more information about the format of I<val>,
296 see L<openssl(1)/Pass Phrase Options>.
300 Tests non blocking I/O.
304 This option translated a line feed from the terminal into CR+LF.
308 Print extensive debugging information including a hex dump of all traffic.
312 Show all protocol messages with hex dump.
314 =item B<-msgfile> I<outfile>
316 File to send output of B<-msg> or B<-trace> to, default standard output.
320 Prints the SSL session states.
322 =item B<-CRL> I<infile>
326 =item B<-CRLform> B<DER>|B<PEM>
328 The CRL file format; the default is B<PEM>.
329 See L<openssl(1)/Format Options> for details.
331 =item B<-crl_download>
333 Download CRLs from distribution points given in CDP extensions of certificates
335 =item B<-verifyCAfile> I<filename>
337 A file in PEM format CA containing trusted certificates to use
338 for verifying client certificates.
340 =item B<-verifyCApath> I<dir>
342 A directory containing trusted certificates to use
343 for verifying client certificates.
344 This directory must be in "hash format",
345 see L<openssl-verify(1)> for more information.
347 =item B<-verifyCAstore> I<uri>
349 The URI of a store containing trusted certificates to use
350 for verifying client certificates.
352 =item B<-chainCAfile> I<file>
354 A file in PEM format containing trusted certificates to use
355 when attempting to build the server certificate chain.
357 =item B<-chainCApath> I<dir>
359 A directory containing trusted certificates to use
360 for building the server certificate chain provided to the client.
361 This directory must be in "hash format",
362 see L<openssl-verify(1)> for more information.
364 =item B<-chainCAstore> I<uri>
366 The URI of a store containing trusted certificates to use
367 for building the server certificate chain provided to the client.
368 The URI may indicate a single certificate, as well as a collection of them.
369 With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
370 B<-chainCApath>, depending on if the URI indicates a directory or a
372 See L<ossl_store-file(7)> for more information on the C<file:> scheme.
376 If this option is set then no certificate is used. This restricts the
377 cipher suites available to the anonymous ones (currently just anonymous
382 Inhibit printing of session and certificate information.
384 =item B<-tlsextdebug>
386 Print a hex dump of any TLS extensions received from the server.
390 Sends a status message back to the client when it connects. This includes
391 information about the ciphers used and various session parameters.
392 The output is in HTML format so this option can be used with a web browser.
393 The special URL C</renegcert> turns on client cert validation, and C</reneg>
394 tells the server to request renegotiation.
395 The B<-early_data> option cannot be used with this option.
397 =item B<-WWW>, B<-HTTP>
399 Emulates a simple web server. Pages will be resolved relative to the
400 current directory, for example if the URL C<https://myhost/page.html> is
401 requested the file F<./page.html> will be sent.
402 If the B<-HTTP> flag is used, the files are sent directly, and should contain
403 any HTTP response headers (including status response line).
404 If the B<-WWW> option is used,
405 the response headers are generated by the server, and the file extension is
406 examined to determine the B<Content-Type> header.
407 Extensions of C<html>, C<htm>, and C<php> are C<text/html> and all others are
409 In addition, the special URL C</stats> will return status
410 information like the B<-www> option.
411 Neither of these options can be used in conjunction with B<-early_data>.
413 =item B<-http_server_binmode>
415 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
416 by the client in binary mode.
418 =item B<-no_ca_names>
420 Disable TLS Extension CA Names. You may want to disable it for security reasons
421 or for compatibility with some Windows TLS implementations crashing when this
422 extension is larger than 1024 bytes.
424 =item B<-ignore_unexpected_eof>
426 Some TLS implementations do not send the mandatory close_notify alert on
427 shutdown. If the application tries to wait for the close_notify alert but the
428 peer closes the connection without sending it, an error is generated. When this
429 option is enabled the peer does not need to send the close_notify alert and a
430 closed connection will be treated as if the close_notify alert was received.
431 For more information on shutting down a connection, see L<SSL_shutdown(3)>.
433 =item B<-id_prefix> I<val>
435 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
436 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
437 servers, when each of which might be generating a unique range of session
438 IDs (eg. with a certain prefix).
440 =item B<-verify_return_error>
442 Verification errors normally just print a message but allow the
443 connection to continue, for debugging purposes.
444 If this option is used, then verification errors close the connection.
448 Enables certificate status request support (aka OCSP stapling).
450 =item B<-status_verbose>
452 Enables certificate status request support (aka OCSP stapling) and gives
453 a verbose printout of the OCSP response.
455 =item B<-status_timeout> I<int>
457 Sets the timeout for OCSP response to I<int> seconds.
459 =item B<-status_url> I<val>
461 Sets a fallback responder URL to use if no responder URL is present in the
462 server certificate. Without this option an error is returned if the server
463 certificate does not contain a responder address.
465 =item B<-status_file> I<infile>
467 Overrides any OCSP responder URLs from the certificate and always provides the
468 OCSP Response stored in the file. The file must be in DER format.
472 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
473 with B<enable-ssl-trace> for this option to work.
477 Provide a brief summary of connection parameters instead of the normal verbose
482 Simple test server which just reverses the text received from the client
483 and sends it back to the server. Also sets B<-brief>. Cannot be used in
484 conjunction with B<-early_data>.
488 Switch on asynchronous mode. Cryptographic operations will be performed
489 asynchronously. This will only have an effect if an asynchronous capable engine
490 is also used via the B<-engine> option. For test purposes the dummy async engine
491 (dasync) can be used (if available).
493 =item B<-max_send_frag> I<+int>
495 The maximum size of data fragment to send.
496 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
498 =item B<-split_send_frag> I<+int>
500 The size used to split data for encrypt pipelines. If more data is written in
501 one go than this value then it will be split into multiple pipelines, up to the
502 maximum number of pipelines defined by max_pipelines. This only has an effect if
503 a suitable cipher suite has been negotiated, an engine that supports pipelining
504 has been loaded, and max_pipelines is greater than 1. See
505 L<SSL_CTX_set_split_send_fragment(3)> for further information.
507 =item B<-max_pipelines> I<+int>
509 The maximum number of encrypt/decrypt pipelines to be used. This will only have
510 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
511 engine) and a suitable cipher suite has been negotiated. The default value is 1.
512 See L<SSL_CTX_set_max_pipelines(3)> for further information.
514 =item B<-naccept> I<+int>
516 The server will exit after receiving the specified number of connections,
519 =item B<-read_buf> I<+int>
521 The default read buffer size to be used for connections. This will only have an
522 effect if the buffer size is larger than the size that would otherwise be used
523 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
524 further information).
528 There are several known bugs in SSL and TLS implementations. Adding this
529 option enables various workarounds.
533 Disable negotiation of TLS compression.
534 TLS compression is not recommended and is off by default as of
539 Enable negotiation of TLS compression.
540 This option was introduced in OpenSSL 1.1.0.
541 TLS compression is not recommended and is off by default as of
546 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
547 is negotiated. See B<-num_tickets>.
549 =item B<-num_tickets>
551 Control the number of tickets that will be sent to the client after a full
552 handshake in TLSv1.3. The default number of tickets is 2. This option does not
553 affect the number of tickets sent after a resumption handshake.
557 Use the server's cipher preferences, rather than the client's preferences.
559 =item B<-prioritize_chacha>
561 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
563 =item B<-no_resumption_on_reneg>
565 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
567 =item B<-client_sigalgs> I<val>
569 Signature algorithms to support for client certificate authentication
570 (colon-separated list).
572 =item B<-named_curve> I<val>
574 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
575 For a list of all possible curves, use:
577 $ openssl ecparam -list_curves
579 =item B<-cipher> I<val>
581 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
582 modified. This list is combined with any TLSv1.3 ciphersuites that have been
583 configured. When the client sends a list of supported ciphers the first client
584 cipher also included in the server list is used. Because the client specifies
585 the preference order, the order of the server cipherlist is irrelevant. See
586 L<openssl-ciphers(1)> for more information.
588 =item B<-ciphersuites> I<val>
590 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
591 This list is combined with any TLSv1.2 and below ciphersuites that have been
592 configured. When the client sends a list of supported ciphers the first client
593 cipher also included in the server list is used. Because the client specifies
594 the preference order, the order of the server cipherlist is irrelevant. See
595 L<openssl-ciphers(1)> command for more information. The format for this list is
596 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
598 =item B<-dhparam> I<infile>
600 The DH parameter file to use. The ephemeral DH cipher suites generate keys
601 using a set of DH parameters. If not specified then an attempt is made to
602 load the parameters from the server certificate file.
603 If this fails then a static set of parameters hard coded into this command
608 Turns on non blocking I/O.
610 =item B<-psk_identity> I<val>
612 Expect the client to send PSK identity I<val> when using a PSK
613 cipher suite, and warn if they do not. By default, the expected PSK
614 identity is the string "Client_identity".
616 =item B<-psk_hint> I<val>
618 Use the PSK identity hint I<val> when using a PSK cipher suite.
622 Use the PSK key I<val> when using a PSK cipher suite. The key is
623 given as a hexadecimal number without leading 0x, for example -psk
625 This option must be provided in order to use a PSK cipher.
627 =item B<-psk_session> I<file>
629 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
630 Note that this will only work if TLSv1.3 is negotiated.
634 This option can only be used in conjunction with one of the DTLS options above.
635 With this option, this command will listen on a UDP port for incoming
637 Any ClientHellos that arrive will be checked to see if they have a cookie in
639 Any without a cookie will be responded to with a HelloVerifyRequest.
640 If a ClientHello with a cookie is received then this command will
641 connect to that peer and complete the handshake.
645 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
646 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
647 available where OpenSSL has support for SCTP enabled.
649 =item B<-sctp_label_bug>
651 Use the incorrect behaviour of older OpenSSL implementations when computing
652 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
653 older broken implementations but breaks interoperability with correct
654 implementations. Must be used in conjunction with B<-sctp>. This option is only
655 available where OpenSSL has support for SCTP enabled.
659 If this option is set then no DH parameters will be loaded effectively
660 disabling the ephemeral DH cipher suites.
662 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
664 These flags enable the Enable the Application-Layer Protocol Negotiation
665 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
666 IETF standard and replaces NPN.
667 The I<val> list is a comma-separated list of supported protocol
668 names. The list should contain the most desirable protocols first.
669 Protocol names are printable ASCII strings, for example "http/1.1" or
671 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
675 If this option is set and KTLS is enabled, SSL_sendfile() will be used
676 instead of BIO_write() to send the HTTP response requested by a client.
677 This option is only valid if B<-WWW> or B<-HTTP> is specified.
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.
691 =item B<-recv_max_early_data> I<int>
693 Specify the hard limit on the maximum number of early data bytes that will
698 Accept early data where possible. Cannot be used in conjunction with B<-www>,
699 B<-WWW>, B<-HTTP> or B<-rev>.
703 Require TLSv1.3 cookies.
705 =item B<-anti_replay>, B<-no_anti_replay>
707 Switches replay protection on or off, respectively. Replay protection is on by
708 default unless overridden by a configuration file. When it is on, OpenSSL will
709 automatically detect if a session ticket has been used more than once, TLSv1.3
710 has been negotiated, and early data is enabled on the server. A full handshake
711 is forced if a session ticket is used a second or subsequent time. Any early
712 data that was sent will be rejected.
714 {- $OpenSSL::safe::opt_name_item -}
716 {- $OpenSSL::safe::opt_version_item -}
718 {- $OpenSSL::safe::opt_s_item -}
720 {- $OpenSSL::safe::opt_x_item -}
722 {- $OpenSSL::safe::opt_trust_item -}
724 {- $OpenSSL::safe::opt_r_item -}
726 {- $OpenSSL::safe::opt_engine_item -}
728 {- $OpenSSL::safe::opt_provider_item -}
730 {- $OpenSSL::safe::opt_v_item -}
732 If the server requests a client certificate, then
733 verification errors are displayed, for debugging, but the command will
734 proceed unless the B<-verify_return_error> option is used.
738 =head1 CONNECTED COMMANDS
740 If a connection request is established with an SSL client and neither the
741 B<-www> nor the B<-WWW> option has been used then normally any data received
742 from the client is displayed and any key presses will be sent to the client.
744 Certain commands are also recognized which perform special operations. These
745 commands are a letter which must appear at the start of a line. They are listed
752 End the current SSL connection but still accept new connections.
756 End the current SSL connection and exit.
760 Renegotiate the SSL session (TLSv1.2 and below only).
764 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
769 Send some plain text down the underlying TCP connection: this should
770 cause the client to disconnect due to a protocol violation.
774 Print out some session cache status information.
778 Send a key update message to the client (TLSv1.3 only)
782 Send a key update message to the client and request one back (TLSv1.3 only)
786 Send a certificate request to the client (TLSv1.3 only)
792 This command can be used to debug SSL clients. To accept connections
793 from a web browser the command:
795 openssl s_server -accept 443 -www
797 can be used for example.
799 Although specifying an empty list of CAs when requesting a client certificate
800 is strictly speaking a protocol violation, some SSL clients interpret this to
801 mean any CA is acceptable. This is useful for debugging purposes.
803 The session parameters can printed out using the L<openssl-sess_id(1)> command.
807 Because this program has a lot of options and also because some of the
808 techniques used are rather old, the C source for this command is rather
809 hard to read and not a model of how things should be done.
810 A typical SSL server program would be much simpler.
812 The output of common ciphers is wrong: it just gives the list of ciphers that
813 OpenSSL recognizes and the client supports.
815 There should be a way for this command to print out details
816 of any unknown cipher suites a client says it supports.
821 L<openssl-sess_id(1)>,
822 L<openssl-s_client(1)>,
823 L<openssl-ciphers(1)>,
825 L<SSL_CTX_set_max_send_fragment(3)>,
826 L<SSL_CTX_set_split_send_fragment(3)>,
827 L<SSL_CTX_set_max_pipelines(3)>,
828 L<ossl_store-file(7)>
832 The -no_alt_chains option was added in OpenSSL 1.1.0.
835 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
837 All B<-keyform> and B<-dkeyform> values except B<ENGINE>
838 have become obsolete in OpenSSL 3.0.0 and have no effect.
840 The B<-certform> and B<-dcertform> options have become obsolete in OpenSSL 3.0.0
845 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
847 Licensed under the Apache License 2.0 (the "License"). You may not use
848 this file except in compliance with the License. You can obtain a copy
849 in the file LICENSE in the source distribution or at
850 L<https://www.openssl.org/source/license.html>.