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>]
24 [B<-cert_chain> I<infile>]
26 [B<-serverinfo> I<val>]
29 [B<-keyform> B<DER>|B<PEM>|B<ENGINE>]
32 [B<-dcertform> B<DER>|B<PEM>]
33 [B<-dcert_chain> I<infile>]
35 [B<-dkeyform> B<DER>|B<PEM>|B<ENGINE>]
41 [B<-msgfile> I<outfile>]
45 [B<-no_resume_ephemeral>]
48 [B<-http_server_binmode>]
51 [B<-servername_fatal>]
54 [B<-id_prefix> I<val>]
55 [B<-keymatexport> I<val>]
56 [B<-keymatexportlen> I<+int>]
58 [B<-CRLform> B<DER>|B<PEM>]
60 [B<-chainCAfile> I<infile>]
61 [B<-chainCApath> I<dir>]
62 [B<-chainCAstore> I<uri>]
63 [B<-verifyCAfile> I<infile>]
64 [B<-verifyCApath> I<dir>]
65 [B<-verifyCAstore> I<uri>]
68 [B<-verify_return_error>]
74 [B<-status_timeout> I<int>]
75 [B<-status_url> I<val>]
76 [B<-status_file> I<infile>]
79 [B<-security_debug_verbose>]
83 [B<-ssl_config> I<val>]
84 [B<-max_send_frag> I<+int>]
85 [B<-split_send_frag> I<+int>]
86 [B<-max_pipelines> I<+int>]
88 [B<-read_buf> I<+int>]
94 [B<-legacy_renegotiation>]
95 [B<-no_renegotiation>]
96 [B<-legacy_server_connect>]
97 [B<-no_resumption_on_reneg>]
98 [B<-no_legacy_server_connect>]
99 [B<-allow_no_dhe_kex>]
100 [B<-prioritize_chacha>]
103 [B<-client_sigalgs> I<val>]
106 [B<-named_curve> I<val>]
108 [B<-ciphersuites> I<val>]
109 [B<-dhparam> I<infile>]
110 [B<-record_padding> I<val>]
111 [B<-debug_broken_protocol>]
113 [B<-psk_identity> I<val>]
114 [B<-psk_hint> I<val>]
116 [B<-psk_session> I<file>]
117 [B<-srpvfile> I<infile>]
118 [B<-srpuserseed> I<val>]
125 [B<-nextprotoneg> I<val>]
126 [B<-use_srtp> I<val>]
129 [B<-keylogfile> I<outfile>]
130 [B<-recv_max_early_data> I<int>]
131 [B<-max_early_data> I<int>]
137 {- $OpenSSL::safe::opt_name_synopsis -}
138 {- $OpenSSL::safe::opt_version_synopsis -}
139 {- $OpenSSL::safe::opt_v_synopsis -}
140 {- $OpenSSL::safe::opt_s_synopsis -}
141 {- $OpenSSL::safe::opt_x_synopsis -}
142 {- $OpenSSL::safe::opt_trust_synopsis -}
143 {- $OpenSSL::safe::opt_r_synopsis -}
144 {- $OpenSSL::safe::opt_engine_synopsis -}
145 {- $OpenSSL::safe::opt_provider_synopsis -}
147 =for openssl ifdef unix 4 6 unlink no_dhe nextprotoneg use_srtp engine
149 =for openssl ifdef status status_verbose status_timeout status_url status_file
151 =for openssl ifdef psk_hint srpvfile srpuserseed sctp sctp_label_bug
153 =for openssl ifdef sctp sctp_label_bug trace mtu timeout listen
155 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
157 =for openssl ifdef sendfile
161 This command implements a generic SSL/TLS server which
162 listens for connections on a given port using SSL/TLS.
166 In addition to the options below, this command also supports
167 the common and server only options documented
168 L<SSL_CONF_cmd(3)/Supported Command Line Commands>
174 Print out a usage message.
176 =item B<-port> I<+int>
178 The TCP port to listen on for connections. If not specified 4433 is used.
180 =item B<-accept> I<val>
182 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
184 =item B<-unix> I<val>
186 Unix domain socket to accept on.
198 For -unix, unlink any existing socket first.
200 =item B<-context> I<val>
202 Sets the SSL context id. It can be given any string value. If this option
203 is not present a default value will be used.
205 =item B<-verify> I<int>, B<-Verify> I<int>
207 The verify depth to use. This specifies the maximum length of the
208 client certificate chain and makes the server request a certificate from
209 the client. With the B<-verify> option a certificate is requested but the
210 client does not have to send one, with the B<-Verify> option the client
211 must supply a certificate or an error occurs.
213 If the cipher suite cannot request a client certificate (for example an
214 anonymous cipher suite or PSK) this option has no effect.
216 =item B<-cert> I<infile>
218 The certificate to use, most servers cipher suites require the use of a
219 certificate and some require a certificate with a certain public key type:
220 for example the DSS cipher suites require a certificate containing a DSS
221 (DSA) key. If not specified then the filename F<server.pem> will be used.
223 =item B<-certform> B<DER>|B<PEM>
225 The server certificate file format; the default is B<PEM>.
226 See L<openssl(1)/Format Options> for details.
230 A file containing untrusted certificates to use when attempting to build the
231 certificate chain related to the certificate specified via the B<-cert> option.
233 =item B<-build_chain>
235 Specify whether the application should build the server certificate chain to be
236 provided to the client.
238 =item B<-serverinfo> I<val>
240 A file containing one or more blocks of PEM data. Each PEM block
241 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
242 followed by "length" bytes of extension data). If the client sends
243 an empty TLS ClientHello extension matching the type, the corresponding
244 ServerHello extension will be returned.
246 =item B<-key> I<infile>
248 The private key to use. If not specified then the certificate file will
251 =item B<-keyform> B<DER>|B<PEM>|B<ENGINE>
253 The key format; the default is B<PEM>.
254 See L<openssl(1)/Format Options> for details.
256 =item B<-pass> I<val>
258 The private key password source.
259 For more information about the format of I<val>,
260 see L<openssl(1)/Pass Phrase Options>.
262 =item B<-dcert> I<infile>, B<-dkey> I<infile>
264 Specify an additional certificate and private key, these behave in the
265 same manner as the B<-cert> and B<-key> options except there is no default
266 if they are not specified (no additional certificate and key is used). As
267 noted above some cipher suites require a certificate containing a key of
268 a certain type. Some cipher suites need a certificate carrying an RSA key
269 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
270 a server can support clients which only support RSA or DSS cipher suites
271 by using an appropriate certificate.
273 =item B<-dcert_chain>
275 A file containing untrusted certificates to use when attempting to build the
276 server certificate chain when a certificate specified via the B<-dcert> option
279 =item B<-dcertform> B<DER>|B<PEM>
281 The format of the additional certificate file; the default is B<PEM>.
282 See L<openssl(1)/Format Options>.
284 =item B<-dkeyform> B<DER>|B<PEM>|B<ENGINE>
286 The format of the additional private key; the default is B<PEM>.
287 See L<openssl(1)/Format Options>.
289 =item B<-dpass> I<val>
291 The passphrase for the additional private key.
292 For more information about the format of I<val>,
293 see L<openssl(1)/Pass Phrase Options>.
297 Tests non blocking I/O.
301 This option translated a line feed from the terminal into CR+LF.
305 Print extensive debugging information including a hex dump of all traffic.
309 Show all protocol messages with hex dump.
311 =item B<-msgfile> I<outfile>
313 File to send output of B<-msg> or B<-trace> to, default standard output.
317 Prints the SSL session states.
319 =item B<-CRL> I<infile>
323 =item B<-CRLform> B<DER>|B<PEM>
325 The CRL file format; the default is B<PEM>.
326 See L<openssl(1)/Format Options> for details.
328 =item B<-crl_download>
330 Download CRLs from distribution points given in CDP extensions of certificates
332 =item B<-verifyCAfile> I<filename>
334 A file in PEM format CA containing trusted certificates to use
335 for verifying client certificates.
337 =item B<-verifyCApath> I<dir>
339 A directory containing trusted certificates to use
340 for verifying client certificates.
341 This directory must be in "hash format",
342 see L<openssl-verify(1)> for more information.
344 =item B<-verifyCAstore> I<uri>
346 The URI of a store containing trusted certificates to use
347 for verifying client certificates.
349 =item B<-chainCAfile> I<file>
351 A file in PEM format containing trusted certificates to use
352 when attempting to build the server certificate chain.
354 =item B<-chainCApath> I<dir>
356 A directory containing trusted certificates to use
357 for building the server certificate chain provided to the client.
358 This directory must be in "hash format",
359 see L<openssl-verify(1)> for more information.
361 =item B<-chainCAstore> I<uri>
363 The URI of a store containing trusted certificates to use
364 for building the server certificate chain provided to the client.
365 The URI may indicate a single certificate, as well as a collection of them.
366 With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
367 B<-chainCApath>, depending on if the URI indicates a directory or a
369 See L<ossl_store-file(7)> for more information on the C<file:> scheme.
373 If this option is set then no certificate is used. This restricts the
374 cipher suites available to the anonymous ones (currently just anonymous
379 Inhibit printing of session and certificate information.
381 =item B<-tlsextdebug>
383 Print a hex dump of any TLS extensions received from the server.
387 Sends a status message back to the client when it connects. This includes
388 information about the ciphers used and various session parameters.
389 The output is in HTML format so this option can be used with a web browser.
390 The special URL C</renegcert> turns on client cert validation, and C</reneg>
391 tells the server to request renegotiation.
392 The B<-early_data> option cannot be used with this option.
394 =item B<-WWW>, B<-HTTP>
396 Emulates a simple web server. Pages will be resolved relative to the
397 current directory, for example if the URL C<https://myhost/page.html> is
398 requested the file F<./page.html> will be sent.
399 If the B<-HTTP> flag is used, the files are sent directly, and should contain
400 any HTTP response headers (including status response line).
401 If the B<-WWW> option is used,
402 the response headers are generated by the server, and the file extension is
403 examined to determine the B<Content-Type> header.
404 Extensions of C<html>, C<htm>, and C<php> are C<text/html> and all others are
406 In addition, the special URL C</stats> will return status
407 information like the B<-www> option.
408 Neither of these options can be used in conjunction with B<-early_data>.
410 =item B<-http_server_binmode>
412 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
413 by the client in binary mode.
415 =item B<-no_ca_names>
417 Disable TLS Extension CA Names. You may want to disable it for security reasons
418 or for compatibility with some Windows TLS implementations crashing when this
419 extension is larger than 1024 bytes.
421 =item B<-id_prefix> I<val>
423 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
424 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
425 servers, when each of which might be generating a unique range of session
426 IDs (eg. with a certain prefix).
428 =item B<-verify_return_error>
430 Verification errors normally just print a message but allow the
431 connection to continue, for debugging purposes.
432 If this option is used, then verification errors close the connection.
436 Enables certificate status request support (aka OCSP stapling).
438 =item B<-status_verbose>
440 Enables certificate status request support (aka OCSP stapling) and gives
441 a verbose printout of the OCSP response.
443 =item B<-status_timeout> I<int>
445 Sets the timeout for OCSP response to I<int> seconds.
447 =item B<-status_url> I<val>
449 Sets a fallback responder URL to use if no responder URL is present in the
450 server certificate. Without this option an error is returned if the server
451 certificate does not contain a responder address.
453 =item B<-status_file> I<infile>
455 Overrides any OCSP responder URLs from the certificate and always provides the
456 OCSP Response stored in the file. The file must be in DER format.
460 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
461 with B<enable-ssl-trace> for this option to work.
465 Provide a brief summary of connection parameters instead of the normal verbose
470 Simple test server which just reverses the text received from the client
471 and sends it back to the server. Also sets B<-brief>. Cannot be used in
472 conjunction with B<-early_data>.
476 Switch on asynchronous mode. Cryptographic operations will be performed
477 asynchronously. This will only have an effect if an asynchronous capable engine
478 is also used via the B<-engine> option. For test purposes the dummy async engine
479 (dasync) can be used (if available).
481 =item B<-max_send_frag> I<+int>
483 The maximum size of data fragment to send.
484 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
486 =item B<-split_send_frag> I<+int>
488 The size used to split data for encrypt pipelines. If more data is written in
489 one go than this value then it will be split into multiple pipelines, up to the
490 maximum number of pipelines defined by max_pipelines. This only has an effect if
491 a suitable cipher suite has been negotiated, an engine that supports pipelining
492 has been loaded, and max_pipelines is greater than 1. See
493 L<SSL_CTX_set_split_send_fragment(3)> for further information.
495 =item B<-max_pipelines> I<+int>
497 The maximum number of encrypt/decrypt pipelines to be used. This will only have
498 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
499 engine) and a suitable cipher suite has been negotiated. The default value is 1.
500 See L<SSL_CTX_set_max_pipelines(3)> for further information.
502 =item B<-naccept> I<+int>
504 The server will exit after receiving the specified number of connections,
507 =item B<-read_buf> I<+int>
509 The default read buffer size to be used for connections. This will only have an
510 effect if the buffer size is larger than the size that would otherwise be used
511 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
512 further information).
516 There are several known bugs in SSL and TLS implementations. Adding this
517 option enables various workarounds.
521 Disable negotiation of TLS compression.
522 TLS compression is not recommended and is off by default as of
527 Enable negotiation of TLS compression.
528 This option was introduced in OpenSSL 1.1.0.
529 TLS compression is not recommended and is off by default as of
534 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
535 is negotiated. See B<-num_tickets>.
537 =item B<-num_tickets>
539 Control the number of tickets that will be sent to the client after a full
540 handshake in TLSv1.3. The default number of tickets is 2. This option does not
541 affect the number of tickets sent after a resumption handshake.
545 Use the server's cipher preferences, rather than the client's preferences.
547 =item B<-prioritize_chacha>
549 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
551 =item B<-no_resumption_on_reneg>
553 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
555 =item B<-client_sigalgs> I<val>
557 Signature algorithms to support for client certificate authentication
558 (colon-separated list).
560 =item B<-named_curve> I<val>
562 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
563 For a list of all possible curves, use:
565 $ openssl ecparam -list_curves
567 =item B<-cipher> I<val>
569 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
570 modified. This list is combined with any TLSv1.3 ciphersuites that have been
571 configured. When the client sends a list of supported ciphers the first client
572 cipher also included in the server list is used. Because the client specifies
573 the preference order, the order of the server cipherlist is irrelevant. See
574 L<openssl-ciphers(1)> for more information.
576 =item B<-ciphersuites> I<val>
578 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
579 This list is combined with any TLSv1.2 and below ciphersuites that have been
580 configured. When the client sends a list of supported ciphers the first client
581 cipher also included in the server list is used. Because the client specifies
582 the preference order, the order of the server cipherlist is irrelevant. See
583 L<openssl-ciphers(1)> command for more information. The format for this list is
584 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
586 =item B<-dhparam> I<infile>
588 The DH parameter file to use. The ephemeral DH cipher suites generate keys
589 using a set of DH parameters. If not specified then an attempt is made to
590 load the parameters from the server certificate file.
591 If this fails then a static set of parameters hard coded into this command
596 Turns on non blocking I/O.
598 =item B<-psk_identity> I<val>
600 Expect the client to send PSK identity I<val> when using a PSK
601 cipher suite, and warn if they do not. By default, the expected PSK
602 identity is the string "Client_identity".
604 =item B<-psk_hint> I<val>
606 Use the PSK identity hint I<val> when using a PSK cipher suite.
610 Use the PSK key I<val> when using a PSK cipher suite. The key is
611 given as a hexadecimal number without leading 0x, for example -psk
613 This option must be provided in order to use a PSK cipher.
615 =item B<-psk_session> I<file>
617 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
618 Note that this will only work if TLSv1.3 is negotiated.
622 This option can only be used in conjunction with one of the DTLS options above.
623 With this option, this command will listen on a UDP port for incoming
625 Any ClientHellos that arrive will be checked to see if they have a cookie in
627 Any without a cookie will be responded to with a HelloVerifyRequest.
628 If a ClientHello with a cookie is received then this command will
629 connect to that peer and complete the handshake.
633 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
634 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
635 available where OpenSSL has support for SCTP enabled.
637 =item B<-sctp_label_bug>
639 Use the incorrect behaviour of older OpenSSL implementations when computing
640 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
641 older broken implementations but breaks interoperability with correct
642 implementations. Must be used in conjunction with B<-sctp>. This option is only
643 available where OpenSSL has support for SCTP enabled.
647 If this option is set then no DH parameters will be loaded effectively
648 disabling the ephemeral DH cipher suites.
650 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
652 These flags enable the Enable the Application-Layer Protocol Negotiation
653 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
654 IETF standard and replaces NPN.
655 The I<val> list is a comma-separated list of supported protocol
656 names. The list should contain the most desirable protocols first.
657 Protocol names are printable ASCII strings, for example "http/1.1" or
659 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
663 If this option is set and KTLS is enabled, SSL_sendfile() will be used
664 instead of BIO_write() to send the HTTP response requested by a client.
665 This option is only valid if B<-WWW> or B<-HTTP> is specified.
667 =item B<-keylogfile> I<outfile>
669 Appends TLS secrets to the specified keylog file such that external programs
670 (like Wireshark) can decrypt TLS connections.
672 =item B<-max_early_data> I<int>
674 Change the default maximum early data bytes that are specified for new sessions
675 and any incoming early data (when used in conjunction with the B<-early_data>
676 flag). The default value is approximately 16k. The argument must be an integer
677 greater than or equal to 0.
679 =item B<-recv_max_early_data> I<int>
681 Specify the hard limit on the maximum number of early data bytes that will
686 Accept early data where possible. Cannot be used in conjunction with B<-www>,
687 B<-WWW>, B<-HTTP> or B<-rev>.
691 Require TLSv1.3 cookies.
693 =item B<-anti_replay>, B<-no_anti_replay>
695 Switches replay protection on or off, respectively. Replay protection is on by
696 default unless overridden by a configuration file. When it is on, OpenSSL will
697 automatically detect if a session ticket has been used more than once, TLSv1.3
698 has been negotiated, and early data is enabled on the server. A full handshake
699 is forced if a session ticket is used a second or subsequent time. Any early
700 data that was sent will be rejected.
702 {- $OpenSSL::safe::opt_name_item -}
704 {- $OpenSSL::safe::opt_version_item -}
706 {- $OpenSSL::safe::opt_s_item -}
708 {- $OpenSSL::safe::opt_x_item -}
710 {- $OpenSSL::safe::opt_trust_item -}
712 {- $OpenSSL::safe::opt_r_item -}
714 {- $OpenSSL::safe::opt_engine_item -}
716 {- $OpenSSL::safe::opt_provider_item -}
718 {- $OpenSSL::safe::opt_v_item -}
720 If the server requests a client certificate, then
721 verification errors are displayed, for debugging, but the command will
722 proceed unless the B<-verify_return_error> option is used.
726 =head1 CONNECTED COMMANDS
728 If a connection request is established with an SSL client and neither the
729 B<-www> nor the B<-WWW> option has been used then normally any data received
730 from the client is displayed and any key presses will be sent to the client.
732 Certain commands are also recognized which perform special operations. These
733 commands are a letter which must appear at the start of a line. They are listed
740 End the current SSL connection but still accept new connections.
744 End the current SSL connection and exit.
748 Renegotiate the SSL session (TLSv1.2 and below only).
752 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
757 Send some plain text down the underlying TCP connection: this should
758 cause the client to disconnect due to a protocol violation.
762 Print out some session cache status information.
766 Send a key update message to the client (TLSv1.3 only)
770 Send a key update message to the client and request one back (TLSv1.3 only)
774 Send a certificate request to the client (TLSv1.3 only)
780 This command can be used to debug SSL clients. To accept connections
781 from a web browser the command:
783 openssl s_server -accept 443 -www
785 can be used for example.
787 Although specifying an empty list of CAs when requesting a client certificate
788 is strictly speaking a protocol violation, some SSL clients interpret this to
789 mean any CA is acceptable. This is useful for debugging purposes.
791 The session parameters can printed out using the L<openssl-sess_id(1)> command.
795 Because this program has a lot of options and also because some of the
796 techniques used are rather old, the C source for this command is rather
797 hard to read and not a model of how things should be done.
798 A typical SSL server program would be much simpler.
800 The output of common ciphers is wrong: it just gives the list of ciphers that
801 OpenSSL recognizes and the client supports.
803 There should be a way for this command to print out details
804 of any unknown cipher suites a client says it supports.
809 L<openssl-sess_id(1)>,
810 L<openssl-s_client(1)>,
811 L<openssl-ciphers(1)>,
813 L<SSL_CTX_set_max_send_fragment(3)>,
814 L<SSL_CTX_set_split_send_fragment(3)>,
815 L<SSL_CTX_set_max_pipelines(3)>,
816 L<ossl_store-file(7)>
820 The -no_alt_chains option was added in OpenSSL 1.1.0.
823 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
827 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
829 Licensed under the Apache License 2.0 (the "License"). You may not use
830 this file except in compliance with the License. You can obtain a copy
831 in the file LICENSE in the source distribution or at
832 L<https://www.openssl.org/source/license.html>.