5 openssl-s_server - SSL/TLS server program
23 [B<-serverinfo> I<val>]
24 [B<-certform> B<DER>|B<PEM>]
26 [B<-keyform> I<format>]
29 [B<-dcertform> B<DER>|B<PEM>]
31 [B<-dkeyform> B<DER>|B<PEM>]
37 [B<-msgfile> I<outfile>]
39 [B<-CAfile> I<infile>]
45 [B<-no_resume_ephemeral>]
49 [B<-servername_fatal>]
54 [B<-id_prefix> I<val>]
56 [B<-writerand> I<file>]
57 [B<-keymatexport> I<val>]
58 [B<-keymatexportlen> I<+int>]
61 [B<-cert_chain> I<infile>]
62 [B<-dcert_chain> I<infile>]
63 [B<-chainCApath> I<dir>]
64 [B<-verifyCApath> I<dir>]
67 [B<-CRLform> B<DER>|B<PEM>]
68 [B<-verify_return_error>]
71 [B<-chainCAfile> I<infile>]
72 [B<-verifyCAfile> I<infile>]
77 [B<-status_timeout> I<int>]
78 [B<-status_url> I<val>]
79 [B<-status_file> I<infile>]
82 [B<-security_debug_verbose>]
86 [B<-ssl_config> I<val>]
87 [B<-max_send_frag> I<+int>]
88 [B<-split_send_frag> I<+int>]
89 [B<-max_pipelines> I<+int>]
90 [B<-read_buf> I<+int>]
102 [B<-legacy_renegotiation>]
103 [B<-no_renegotiation>]
104 [B<-legacy_server_connect>]
105 [B<-no_resumption_on_reneg>]
106 [B<-no_legacy_server_connect>]
107 [B<-allow_no_dhe_kex>]
108 [B<-prioritize_chacha>]
111 [B<-client_sigalgs> I<val>]
114 [B<-named_curve> I<val>]
116 [B<-ciphersuites> I<val>]
117 [B<-dhparam> I<infile>]
118 [B<-record_padding> I<val>]
119 [B<-debug_broken_protocol>]
122 [B<-verify_name> I<val>]
123 [B<-verify_depth> I<int>]
124 [B<-auth_level> I<int>]
125 [B<-attime> I<intmax>]
126 [B<-verify_hostname> I<val>]
127 [B<-verify_email> I<val>]
129 [B<-ignore_critical>]
134 [B<-explicit_policy>]
143 [B<-suiteB_128_only>]
149 [B<-allow_proxy_certs>]
154 [B<-xcertform> B<DER>|B<PEM>]
155 [B<-xkeyform> B<DER>|B<PEM>]
157 [B<-psk_identity> I<val>]
158 [B<-psk_hint> I<val>]
160 [B<-psk_session> I<file>]
161 [B<-srpvfile> I<infile>]
162 [B<-srpuserseed> I<val>]
177 [B<-nextprotoneg> I<val>]
178 [B<-use_srtp> I<val>]
181 [B<-keylogfile> I<outfile>]
182 [B<-max_early_data> I<int>]
186 [B<-http_server_binmode>]
188 =for openssl ifdef unix 4 6 unlink no_dhe nextprotoneg use_srtp engine
190 =for openssl ifdef status status_verbose status_timeout status_url status_file
192 =for openssl ifdef psk_hint srpvfile srpuserseed sctp sctp_label_bug
194 =for openssl ifdef sctp sctp_label_bug trace mtu timeout listen
196 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
200 This command implements a generic SSL/TLS server which
201 listens for connections on a given port using SSL/TLS.
205 In addition to the options below, this command also supports
206 the common and server only options documented
207 L<SSL_CONF_cmd(3)/Supported Command Line Commands>
213 Print out a usage message.
215 =item B<-port> I<+int>
217 The TCP port to listen on for connections. If not specified 4433 is used.
219 =item B<-accept> I<val>
221 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
223 =item B<-unix> I<val>
225 Unix domain socket to accept on.
237 For -unix, unlink any existing socket first.
239 =item B<-context> I<val>
241 Sets the SSL context id. It can be given any string value. If this option
242 is not present a default value will be used.
244 =item B<-verify> I<int>, B<-Verify> I<int>
246 The verify depth to use. This specifies the maximum length of the
247 client certificate chain and makes the server request a certificate from
248 the client. With the B<-verify> option a certificate is requested but the
249 client does not have to send one, with the B<-Verify> option the client
250 must supply a certificate or an error occurs.
252 If the cipher suite cannot request a client certificate (for example an
253 anonymous cipher suite or PSK) this option has no effect.
255 =item B<-cert> I<infile>
257 The certificate to use, most servers cipher suites require the use of a
258 certificate and some require a certificate with a certain public key type:
259 for example the DSS cipher suites require a certificate containing a DSS
260 (DSA) key. If not specified then the filename F<server.pem> will be used.
264 A file containing trusted certificates to use when attempting to build the
265 client/server certificate chain related to the certificate specified via the
268 =item B<-build_chain>
270 Specify whether the application should build the certificate chain to be
271 provided to the client.
273 =item B<-nameopt> I<val>
275 Option which determines how the subject or issuer names are displayed. The
276 I<val> argument can be a single option or multiple options separated by
277 commas. Alternatively the B<-nameopt> switch may be used more than once to
278 set multiple options. See the L<openssl-x509(1)> manual page for details.
280 =item B<-naccept> I<+int>
282 The server will exit after receiving the specified number of connections,
285 =item B<-serverinfo> I<val>
287 A file containing one or more blocks of PEM data. Each PEM block
288 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
289 followed by "length" bytes of extension data). If the client sends
290 an empty TLS ClientHello extension matching the type, the corresponding
291 ServerHello extension will be returned.
293 =item B<-certform> B<DER>|B<PEM>
295 The certificate format to use: DER or PEM. PEM is the default.
297 =item B<-key> I<infile>
299 The private key to use. If not specified then the certificate file will
302 =item B<-keyform> I<format>
304 The private format to use: DER or PEM. PEM is the default.
306 =item B<-pass> I<val>
308 The private key password source. For more information about the format of B<val>
309 see L<openssl(1)/Pass Phrase Options>.
311 =item B<-dcert> I<infile>, B<-dkey> I<infile>
313 Specify an additional certificate and private key, these behave in the
314 same manner as the B<-cert> and B<-key> options except there is no default
315 if they are not specified (no additional certificate and key is used). As
316 noted above some cipher suites require a certificate containing a key of
317 a certain type. Some cipher suites need a certificate carrying an RSA key
318 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
319 a server can support clients which only support RSA or DSS cipher suites
320 by using an appropriate certificate.
322 =item B<-dcert_chain>
324 A file containing trusted certificates to use when attempting to build the
325 server certificate chain when a certificate specified via the B<-dcert> option
328 =item B<-dcertform> B<DER>|B<PEM>, B<-dkeyform> B<DER>|B<PEM>, B<-dpass> I<val>
330 Additional certificate and private key format and passphrase respectively.
332 =item B<-xkey> I<infile>, B<-xcert> I<infile>, B<-xchain>
334 Specify an extra certificate, private key and certificate chain. These behave
335 in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
336 specified, the callback returning the first valid chain will be in use by
339 =item B<-xchain_build>
341 Specify whether the application should build the certificate chain to be
342 provided to the client for the extra certificates provided via B<-xkey> I<infile>,
343 B<-xcert> I<infile>, B<-xchain> options.
345 =item B<-xcertform> B<DER>|B<PEM>, B<-xkeyform> B<DER>|B<PEM>
347 Extra certificate and private key format respectively.
351 Tests non blocking I/O.
355 This option translated a line feed from the terminal into CR+LF.
359 Print extensive debugging information including a hex dump of all traffic.
363 Show all protocol messages with hex dump.
365 =item B<-msgfile> I<outfile>
367 File to send output of B<-msg> or B<-trace> to, default standard output.
371 Prints the SSL session states.
373 =item B<-CAfile> I<infile>
375 A file containing trusted certificates to use during client authentication
376 and to use when attempting to build the server certificate chain. The list
377 is also used in the list of acceptable client CAs passed to the client when
378 a certificate is requested.
380 =item B<-CApath> I<dir>
382 The directory to use for client certificate verification. This directory
383 must be in "hash format", see L<openssl-verify(1)> for more information.
384 These are also used when building the server certificate chain.
386 =item B<-chainCApath> I<dir>
388 The directory to use for building the chain provided to the client. This
389 directory must be in "hash format", see L<openssl-verify(1)> for more
392 =item B<-chainCAfile> I<file>
394 A file containing trusted certificates to use when attempting to build the
395 server certificate chain.
399 Do not load the trusted CA certificates from the default file location.
403 Do not load the trusted CA certificates from the default directory location.
407 If this option is set then no certificate is used. This restricts the
408 cipher suites available to the anonymous ones (currently just anonymous
413 Inhibit printing of session and certificate information.
417 Sends a status message back to the client when it connects. This includes
418 information about the ciphers used and various session parameters.
419 The output is in HTML format so this option will normally be used with a
420 web browser. Cannot be used in conjunction with B<-early_data>.
424 Emulates a simple web server. Pages will be resolved relative to the
425 current directory, for example if the URL https://myhost/page.html is
426 requested the file F<./page.html> will be loaded. Cannot be used in conjunction
429 =item B<-tlsextdebug>
431 Print a hex dump of any TLS extensions received from the server.
435 Emulates a simple web server. Pages will be resolved relative to the
436 current directory, for example if the URL https://myhost/page.html is
437 requested the file F<./page.html> will be loaded. The files loaded are
438 assumed to contain a complete and correct HTTP response (lines that
439 are part of the HTTP response line and headers must end with CRLF). Cannot be
440 used in conjunction with B<-early_data>.
442 =item B<-id_prefix> I<val>
444 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
445 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
446 servers, when each of which might be generating a unique range of session
447 IDs (eg. with a certain prefix).
449 =item B<-rand> I<files>
451 The files containing random data used to seed the random number generator.
452 Multiple files can be specified separated by an OS-dependent character.
453 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
456 =item B<-writerand> I<file>
458 Writes random data to the specified I<file> upon exit.
459 This can be used with a subsequent B<-rand> flag.
461 =item B<-verify_return_error>
463 Verification errors normally just print a message but allow the
464 connection to continue, for debugging purposes.
465 If this option is used, then verification errors close the connection.
469 Enables certificate status request support (aka OCSP stapling).
471 =item B<-status_verbose>
473 Enables certificate status request support (aka OCSP stapling) and gives
474 a verbose printout of the OCSP response.
476 =item B<-status_timeout> I<int>
478 Sets the timeout for OCSP response to I<int> seconds.
480 =item B<-status_url> I<val>
482 Sets a fallback responder URL to use if no responder URL is present in the
483 server certificate. Without this option an error is returned if the server
484 certificate does not contain a responder address.
486 =item B<-status_file> I<infile>
488 Overrides any OCSP responder URLs from the certificate and always provides the
489 OCSP Response stored in the file. The file must be in DER format.
493 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
494 with B<enable-ssl-trace> for this option to work.
498 Provide a brief summary of connection parameters instead of the normal verbose
503 Simple test server which just reverses the text received from the client
504 and sends it back to the server. Also sets B<-brief>. Cannot be used in
505 conjunction with B<-early_data>.
509 Switch on asynchronous mode. Cryptographic operations will be performed
510 asynchronously. This will only have an effect if an asynchronous capable engine
511 is also used via the B<-engine> option. For test purposes the dummy async engine
512 (dasync) can be used (if available).
514 =item B<-max_send_frag> I<+int>
516 The maximum size of data fragment to send.
517 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
519 =item B<-split_send_frag> I<+int>
521 The size used to split data for encrypt pipelines. If more data is written in
522 one go than this value then it will be split into multiple pipelines, up to the
523 maximum number of pipelines defined by max_pipelines. This only has an effect if
524 a suitable cipher suite has been negotiated, an engine that supports pipelining
525 has been loaded, and max_pipelines is greater than 1. See
526 L<SSL_CTX_set_split_send_fragment(3)> for further information.
528 =item B<-max_pipelines> I<+int>
530 The maximum number of encrypt/decrypt pipelines to be used. This will only have
531 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
532 engine) and a suitable cipher suite has been negotiated. The default value is 1.
533 See L<SSL_CTX_set_max_pipelines(3)> for further information.
535 =item B<-read_buf> I<+int>
537 The default read buffer size to be used for connections. This will only have an
538 effect if the buffer size is larger than the size that would otherwise be used
539 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
540 further information).
542 =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>
544 These options require or disable the use of the specified SSL or TLS protocols.
545 By default, this command will negotiate the highest mutually supported
547 When a specific TLS version is required, only that version will be accepted
549 Note that not all protocols and flags may be available, depending on how
554 There are several known bugs in SSL and TLS implementations. Adding this
555 option enables various workarounds.
559 Disable negotiation of TLS compression.
560 TLS compression is not recommended and is off by default as of
565 Enable negotiation of TLS compression.
566 This option was introduced in OpenSSL 1.1.0.
567 TLS compression is not recommended and is off by default as of
572 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
573 is negotiated. See B<-num_tickets>.
575 =item B<-num_tickets>
577 Control the number of tickets that will be sent to the client after a full
578 handshake in TLSv1.3. The default number of tickets is 2. This option does not
579 affect the number of tickets sent after a resumption handshake.
583 Use the server's cipher preferences, rather than the client's preferences.
585 =item B<-prioritize_chacha>
587 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
589 =item B<-no_resumption_on_reneg>
591 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
593 =item B<-client_sigalgs> I<val>
595 Signature algorithms to support for client certificate authentication
596 (colon-separated list).
598 =item B<-named_curve> I<val>
600 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
601 For a list of all possible curves, use:
603 $ openssl ecparam -list_curves
605 =item B<-cipher> I<val>
607 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
608 modified. This list is combined with any TLSv1.3 ciphersuites that have been
609 configured. When the client sends a list of supported ciphers the first client
610 cipher also included in the server list is used. Because the client specifies
611 the preference order, the order of the server cipherlist is irrelevant. See
612 L<openssl-ciphers(1)> for more information.
614 =item B<-ciphersuites> I<val>
616 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
617 This list is combined with any TLSv1.2 and below ciphersuites that have been
618 configured. When the client sends a list of supported ciphers the first client
619 cipher also included in the server list is used. Because the client specifies
620 the preference order, the order of the server cipherlist is irrelevant. See
621 L<openssl-ciphers(1)> command for more information. The format for this list is
622 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
624 =item B<-dhparam> I<infile>
626 The DH parameter file to use. The ephemeral DH cipher suites generate keys
627 using a set of DH parameters. If not specified then an attempt is made to
628 load the parameters from the server certificate file.
629 If this fails then a static set of parameters hard coded into this command
632 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
633 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
634 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
635 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
636 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
637 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
638 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
640 Set different peer certificate verification options.
641 See the L<openssl-verify(1)> manual page for details.
643 =item B<-crl_check>, B<-crl_check_all>
645 Check the peer certificate has not been revoked by its CA.
646 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
647 option all CRLs of all CAs in the chain are checked.
651 Turns on non blocking I/O.
653 =item B<-psk_identity> I<val>
655 Expect the client to send PSK identity I<val> when using a PSK
656 cipher suite, and warn if they do not. By default, the expected PSK
657 identity is the string "Client_identity".
659 =item B<-psk_hint> I<val>
661 Use the PSK identity hint I<val> when using a PSK cipher suite.
665 Use the PSK key I<val> when using a PSK cipher suite. The key is
666 given as a hexadecimal number without leading 0x, for example -psk
668 This option must be provided in order to use a PSK cipher.
670 =item B<-psk_session> I<file>
672 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
673 Note that this will only work if TLSv1.3 is negotiated.
677 This option can only be used in conjunction with one of the DTLS options above.
678 With this option, this command will listen on a UDP port for incoming
680 Any ClientHellos that arrive will be checked to see if they have a cookie in
682 Any without a cookie will be responded to with a HelloVerifyRequest.
683 If a ClientHello with a cookie is received then this command will
684 connect to that peer and complete the handshake.
686 =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
688 These options make this command use DTLS protocols instead of TLS.
689 With B<-dtls>, it will negotiate any supported DTLS protocol
690 version, whilst B<-dtls1> and B<-dtls1_2> will only support DTLSv1.0 and
691 DTLSv1.2 respectively.
695 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
696 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
697 available where OpenSSL has support for SCTP enabled.
699 =item B<-sctp_label_bug>
701 Use the incorrect behaviour of older OpenSSL implementations when computing
702 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
703 older broken implementations but breaks interoperability with correct
704 implementations. Must be used in conjunction with B<-sctp>. This option is only
705 available where OpenSSL has support for SCTP enabled.
709 If this option is set then no DH parameters will be loaded effectively
710 disabling the ephemeral DH cipher suites.
712 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
714 These flags enable the Enable the Application-Layer Protocol Negotiation
715 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
716 IETF standard and replaces NPN.
717 The I<val> list is a comma-separated list of supported protocol
718 names. The list should contain the most desirable protocols first.
719 Protocol names are printable ASCII strings, for example "http/1.1" or
721 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
723 =item B<-engine> I<val>
725 Specifying an engine (by its unique id string in I<val>) will cause
726 this command to attempt to obtain a functional reference to the
727 specified engine, thus initialising it if needed. The engine will then be
728 set as the default for all available algorithms.
730 =item B<-keylogfile> I<outfile>
732 Appends TLS secrets to the specified keylog file such that external programs
733 (like Wireshark) can decrypt TLS connections.
735 =item B<-max_early_data> I<int>
737 Change the default maximum early data bytes that are specified for new sessions
738 and any incoming early data (when used in conjunction with the B<-early_data>
739 flag). The default value is approximately 16k. The argument must be an integer
740 greater than or equal to 0.
744 Accept early data where possible. Cannot be used in conjunction with B<-www>,
745 B<-WWW>, B<-HTTP> or B<-rev>.
747 =item B<-anti_replay>, B<-no_anti_replay>
749 Switches replay protection on or off, respectively. Replay protection is on by
750 default unless overridden by a configuration file. When it is on, OpenSSL will
751 automatically detect if a session ticket has been used more than once, TLSv1.3
752 has been negotiated, and early data is enabled on the server. A full handshake
753 is forced if a session ticket is used a second or subsequent time. Any early
754 data that was sent will be rejected.
756 =item B<-http_server_binmode>
758 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
759 by the client in binary mode.
763 =head1 CONNECTED COMMANDS
765 If a connection request is established with an SSL client and neither the
766 B<-www> nor the B<-WWW> option has been used then normally any data received
767 from the client is displayed and any key presses will be sent to the client.
769 Certain commands are also recognized which perform special operations. These
770 commands are a letter which must appear at the start of a line. They are listed
777 End the current SSL connection but still accept new connections.
781 End the current SSL connection and exit.
785 Renegotiate the SSL session (TLSv1.2 and below only).
789 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
794 Send some plain text down the underlying TCP connection: this should
795 cause the client to disconnect due to a protocol violation.
799 Print out some session cache status information.
803 Send a key update message to the client (TLSv1.3 only)
807 Send a key update message to the client and request one back (TLSv1.3 only)
811 Send a certificate request to the client (TLSv1.3 only)
817 This command can be used to debug SSL clients. To accept connections
818 from a web browser the command:
820 openssl s_server -accept 443 -www
822 can be used for example.
824 Although specifying an empty list of CAs when requesting a client certificate
825 is strictly speaking a protocol violation, some SSL clients interpret this to
826 mean any CA is acceptable. This is useful for debugging purposes.
828 The session parameters can printed out using the L<openssl-sess_id(1)> command.
832 Because this program has a lot of options and also because some of the
833 techniques used are rather old, the C source for this command is rather
834 hard to read and not a model of how things should be done.
835 A typical SSL server program would be much simpler.
837 The output of common ciphers is wrong: it just gives the list of ciphers that
838 OpenSSL recognizes and the client supports.
840 There should be a way for this command to print out details
841 of any unknown cipher suites a client says it supports.
846 L<openssl-sess_id(1)>,
847 L<openssl-s_client(1)>,
848 L<openssl-ciphers(1)>,
850 L<SSL_CTX_set_max_send_fragment(3)>,
851 L<SSL_CTX_set_split_send_fragment(3)>,
852 L<SSL_CTX_set_max_pipelines(3)>
856 The -no_alt_chains option was added in OpenSSL 1.1.0.
859 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
863 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
865 Licensed under the Apache License 2.0 (the "License"). You may not use
866 this file except in compliance with the License. You can obtain a copy
867 in the file LICENSE in the source distribution or at
868 L<https://www.openssl.org/source/license.html>.