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>]
92 [B<-legacy_renegotiation>]
93 [B<-no_renegotiation>]
94 [B<-legacy_server_connect>]
95 [B<-no_resumption_on_reneg>]
96 [B<-no_legacy_server_connect>]
97 [B<-allow_no_dhe_kex>]
98 [B<-prioritize_chacha>]
101 [B<-client_sigalgs> I<val>]
104 [B<-named_curve> I<val>]
106 [B<-ciphersuites> I<val>]
107 [B<-dhparam> I<infile>]
108 [B<-record_padding> I<val>]
109 [B<-debug_broken_protocol>]
112 [B<-verify_name> I<val>]
113 [B<-verify_depth> I<int>]
114 [B<-auth_level> I<int>]
115 [B<-attime> I<intmax>]
116 [B<-verify_hostname> I<val>]
117 [B<-verify_email> I<val>]
119 [B<-ignore_critical>]
124 [B<-explicit_policy>]
133 [B<-suiteB_128_only>]
139 [B<-allow_proxy_certs>]
141 [B<-psk_identity> I<val>]
142 [B<-psk_hint> I<val>]
144 [B<-psk_session> I<file>]
145 [B<-srpvfile> I<infile>]
146 [B<-srpuserseed> I<val>]
153 [B<-nextprotoneg> I<val>]
154 [B<-use_srtp> I<val>]
156 [B<-keylogfile> I<outfile>]
157 [B<-max_early_data> I<int>]
161 [B<-http_server_binmode>]
162 {- $OpenSSL::safe::opt_name_synopsis -}
163 {- $OpenSSL::safe::opt_version_synopsis -}
164 {- $OpenSSL::safe::opt_x_synopsis -}
165 {- $OpenSSL::safe::opt_trust_synopsis -}
166 {- $OpenSSL::safe::opt_r_synopsis -}
167 {- $OpenSSL::safe::opt_engine_synopsis -}
169 =for openssl ifdef unix 4 6 unlink no_dhe nextprotoneg use_srtp engine
171 =for openssl ifdef status status_verbose status_timeout status_url status_file
173 =for openssl ifdef psk_hint srpvfile srpuserseed sctp sctp_label_bug
175 =for openssl ifdef sctp sctp_label_bug trace mtu timeout listen
177 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
181 This command implements a generic SSL/TLS server which
182 listens for connections on a given port using SSL/TLS.
186 In addition to the options below, this command also supports
187 the common and server only options documented
188 L<SSL_CONF_cmd(3)/Supported Command Line Commands>
194 Print out a usage message.
196 =item B<-port> I<+int>
198 The TCP port to listen on for connections. If not specified 4433 is used.
200 =item B<-accept> I<val>
202 The optional TCP host and port to listen on for connections. If not specified, *:4433 is used.
204 =item B<-unix> I<val>
206 Unix domain socket to accept on.
218 For -unix, unlink any existing socket first.
220 =item B<-context> I<val>
222 Sets the SSL context id. It can be given any string value. If this option
223 is not present a default value will be used.
225 =item B<-verify> I<int>, B<-Verify> I<int>
227 The verify depth to use. This specifies the maximum length of the
228 client certificate chain and makes the server request a certificate from
229 the client. With the B<-verify> option a certificate is requested but the
230 client does not have to send one, with the B<-Verify> option the client
231 must supply a certificate or an error occurs.
233 If the cipher suite cannot request a client certificate (for example an
234 anonymous cipher suite or PSK) this option has no effect.
236 =item B<-cert> I<infile>
238 The certificate to use, most servers cipher suites require the use of a
239 certificate and some require a certificate with a certain public key type:
240 for example the DSS cipher suites require a certificate containing a DSS
241 (DSA) key. If not specified then the filename F<server.pem> will be used.
245 A file containing trusted certificates to use when attempting to build the
246 client/server certificate chain related to the certificate specified via the
249 =item B<-build_chain>
251 Specify whether the application should build the certificate chain to be
252 provided to the client.
254 =item B<-naccept> I<+int>
256 The server will exit after receiving the specified number of connections,
259 =item B<-serverinfo> I<val>
261 A file containing one or more blocks of PEM data. Each PEM block
262 must encode a TLS ServerHello extension (2 bytes type, 2 bytes length,
263 followed by "length" bytes of extension data). If the client sends
264 an empty TLS ClientHello extension matching the type, the corresponding
265 ServerHello extension will be returned.
267 =item B<-certform> B<DER>|B<PEM>, B<-CRLForm> B<DER>|B<PEM>
269 The certificate and CRL format; the default is PEM.
270 See L<openssl(1)/Format Options> for details.
272 =item B<-key> I<infile>
274 The private key to use. If not specified then the certificate file will
277 =item B<-keyform> B<DER>|B<PEM>
279 The key format; the default is B<PEM>.
280 See L<openssl(1)/Format Options> for details.
282 =item B<-pass> I<val>
284 The private key password source.
285 For more information about the format of I<val>,
286 see L<openssl(1)/Pass Phrase Options>.
288 =item B<-dcert> I<infile>, B<-dkey> I<infile>
290 Specify an additional certificate and private key, these behave in the
291 same manner as the B<-cert> and B<-key> options except there is no default
292 if they are not specified (no additional certificate and key is used). As
293 noted above some cipher suites require a certificate containing a key of
294 a certain type. Some cipher suites need a certificate carrying an RSA key
295 and some a DSS (DSA) key. By using RSA and DSS certificates and keys
296 a server can support clients which only support RSA or DSS cipher suites
297 by using an appropriate certificate.
299 =item B<-dcert_chain>
301 A file containing trusted certificates to use when attempting to build the
302 server certificate chain when a certificate specified via the B<-dcert> option
305 =item B<-dcertform> B<DER>|B<PEM>, B<-dkeyform> B<DER>|B<PEM>
307 The format of the certificate and private key; the default is B<PEM>
308 see L<openssl(1)/Format Options>.
310 =item B<-dpass> I<val>
312 The passphrase for the additional private key.
313 For more information about the format of I<val>,
314 see L<openssl(1)/Pass Phrase Options>.
318 Tests non blocking I/O.
322 This option translated a line feed from the terminal into CR+LF.
326 Print extensive debugging information including a hex dump of all traffic.
330 Show all protocol messages with hex dump.
332 =item B<-msgfile> I<outfile>
334 File to send output of B<-msg> or B<-trace> to, default standard output.
338 Prints the SSL session states.
340 =item B<-chainCApath> I<dir>
342 The directory to use for building the chain provided to the client. This
343 directory must be in "hash format", see L<openssl-verify(1)> for more
346 =item B<-chainCAfile> I<file>
348 A file containing trusted certificates to use when attempting to build the
349 server certificate chain.
351 =item B<-chainCAstore> I<uri>
353 The URI to a store to use for building the chain provided to the client.
354 The URI may indicate a single certificate, as well as a collection of
356 With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
357 B<-chainCApath>, depending on if the URI indicates a directory or a
359 See L<ossl_store-file(7)> for more information on the C<file:> scheme.
363 If this option is set then no certificate is used. This restricts the
364 cipher suites available to the anonymous ones (currently just anonymous
369 Inhibit printing of session and certificate information.
373 Sends a status message back to the client when it connects. This includes
374 information about the ciphers used and various session parameters.
375 The output is in HTML format so this option will normally be used with a
376 web browser. Cannot be used in conjunction with B<-early_data>.
380 Emulates a simple web server. Pages will be resolved relative to the
381 current directory, for example if the URL https://myhost/page.html is
382 requested the file F<./page.html> will be loaded.
384 assumed to contain a complete and correct HTTP response (lines that
385 are part of the HTTP response line and headers must end with CRLF). Cannot be
386 used in conjunction with B<-early_data>.
387 Cannot be used in conjunction
390 =item B<-tlsextdebug>
392 Print a hex dump of any TLS extensions received from the server.
394 =item B<-id_prefix> I<val>
396 Generate SSL/TLS session IDs prefixed by I<val>. This is mostly useful
397 for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
398 servers, when each of which might be generating a unique range of session
399 IDs (eg. with a certain prefix).
401 =item B<-verify_return_error>
403 Verification errors normally just print a message but allow the
404 connection to continue, for debugging purposes.
405 If this option is used, then verification errors close the connection.
409 Enables certificate status request support (aka OCSP stapling).
411 =item B<-status_verbose>
413 Enables certificate status request support (aka OCSP stapling) and gives
414 a verbose printout of the OCSP response.
416 =item B<-status_timeout> I<int>
418 Sets the timeout for OCSP response to I<int> seconds.
420 =item B<-status_url> I<val>
422 Sets a fallback responder URL to use if no responder URL is present in the
423 server certificate. Without this option an error is returned if the server
424 certificate does not contain a responder address.
426 =item B<-status_file> I<infile>
428 Overrides any OCSP responder URLs from the certificate and always provides the
429 OCSP Response stored in the file. The file must be in DER format.
433 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
434 with B<enable-ssl-trace> for this option to work.
438 Provide a brief summary of connection parameters instead of the normal verbose
443 Simple test server which just reverses the text received from the client
444 and sends it back to the server. Also sets B<-brief>. Cannot be used in
445 conjunction with B<-early_data>.
449 Switch on asynchronous mode. Cryptographic operations will be performed
450 asynchronously. This will only have an effect if an asynchronous capable engine
451 is also used via the B<-engine> option. For test purposes the dummy async engine
452 (dasync) can be used (if available).
454 =item B<-max_send_frag> I<+int>
456 The maximum size of data fragment to send.
457 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
459 =item B<-split_send_frag> I<+int>
461 The size used to split data for encrypt pipelines. If more data is written in
462 one go than this value then it will be split into multiple pipelines, up to the
463 maximum number of pipelines defined by max_pipelines. This only has an effect if
464 a suitable cipher suite has been negotiated, an engine that supports pipelining
465 has been loaded, and max_pipelines is greater than 1. See
466 L<SSL_CTX_set_split_send_fragment(3)> for further information.
468 =item B<-max_pipelines> I<+int>
470 The maximum number of encrypt/decrypt pipelines to be used. This will only have
471 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
472 engine) and a suitable cipher suite has been negotiated. The default value is 1.
473 See L<SSL_CTX_set_max_pipelines(3)> for further information.
475 =item B<-read_buf> I<+int>
477 The default read buffer size to be used for connections. This will only have an
478 effect if the buffer size is larger than the size that would otherwise be used
479 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
480 further information).
484 There are several known bugs in SSL and TLS implementations. Adding this
485 option enables various workarounds.
489 Disable negotiation of TLS compression.
490 TLS compression is not recommended and is off by default as of
495 Enable negotiation of TLS compression.
496 This option was introduced in OpenSSL 1.1.0.
497 TLS compression is not recommended and is off by default as of
502 Disable RFC4507bis session ticket support. This option has no effect if TLSv1.3
503 is negotiated. See B<-num_tickets>.
505 =item B<-num_tickets>
507 Control the number of tickets that will be sent to the client after a full
508 handshake in TLSv1.3. The default number of tickets is 2. This option does not
509 affect the number of tickets sent after a resumption handshake.
513 Use the server's cipher preferences, rather than the client's preferences.
515 =item B<-prioritize_chacha>
517 Prioritize ChaCha ciphers when preferred by clients. Requires B<-serverpref>.
519 =item B<-no_resumption_on_reneg>
521 Set the B<SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION> option.
523 =item B<-client_sigalgs> I<val>
525 Signature algorithms to support for client certificate authentication
526 (colon-separated list).
528 =item B<-named_curve> I<val>
530 Specifies the elliptic curve to use. NOTE: this is single curve, not a list.
531 For a list of all possible curves, use:
533 $ openssl ecparam -list_curves
535 =item B<-cipher> I<val>
537 This allows the list of TLSv1.2 and below ciphersuites used by the server to be
538 modified. This list is combined with any TLSv1.3 ciphersuites that have been
539 configured. When the client sends a list of supported ciphers the first client
540 cipher also included in the server list is used. Because the client specifies
541 the preference order, the order of the server cipherlist is irrelevant. See
542 L<openssl-ciphers(1)> for more information.
544 =item B<-ciphersuites> I<val>
546 This allows the list of TLSv1.3 ciphersuites used by the server to be modified.
547 This list is combined with any TLSv1.2 and below ciphersuites that have been
548 configured. When the client sends a list of supported ciphers the first client
549 cipher also included in the server list is used. Because the client specifies
550 the preference order, the order of the server cipherlist is irrelevant. See
551 L<openssl-ciphers(1)> command for more information. The format for this list is
552 a simple colon (":") separated list of TLSv1.3 ciphersuite names.
554 =item B<-dhparam> I<infile>
556 The DH parameter file to use. The ephemeral DH cipher suites generate keys
557 using a set of DH parameters. If not specified then an attempt is made to
558 load the parameters from the server certificate file.
559 If this fails then a static set of parameters hard coded into this command
562 =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
563 B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
564 B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
565 B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
566 B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
567 B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
568 B<-verify_ip>, B<-verify_name>, B<-x509_strict>
570 Set different peer certificate verification options.
571 See the L<openssl-verify(1)> manual page for details.
573 =item B<-crl_check>, B<-crl_check_all>
575 Check the peer certificate has not been revoked by its CA.
576 The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
577 option all CRLs of all CAs in the chain are checked.
581 Turns on non blocking I/O.
583 =item B<-psk_identity> I<val>
585 Expect the client to send PSK identity I<val> when using a PSK
586 cipher suite, and warn if they do not. By default, the expected PSK
587 identity is the string "Client_identity".
589 =item B<-psk_hint> I<val>
591 Use the PSK identity hint I<val> when using a PSK cipher suite.
595 Use the PSK key I<val> when using a PSK cipher suite. The key is
596 given as a hexadecimal number without leading 0x, for example -psk
598 This option must be provided in order to use a PSK cipher.
600 =item B<-psk_session> I<file>
602 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
603 Note that this will only work if TLSv1.3 is negotiated.
607 This option can only be used in conjunction with one of the DTLS options above.
608 With this option, this command will listen on a UDP port for incoming
610 Any ClientHellos that arrive will be checked to see if they have a cookie in
612 Any without a cookie will be responded to with a HelloVerifyRequest.
613 If a ClientHello with a cookie is received then this command will
614 connect to that peer and complete the handshake.
618 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
619 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
620 available where OpenSSL has support for SCTP enabled.
622 =item B<-sctp_label_bug>
624 Use the incorrect behaviour of older OpenSSL implementations when computing
625 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
626 older broken implementations but breaks interoperability with correct
627 implementations. Must be used in conjunction with B<-sctp>. This option is only
628 available where OpenSSL has support for SCTP enabled.
632 If this option is set then no DH parameters will be loaded effectively
633 disabling the ephemeral DH cipher suites.
635 =item B<-alpn> I<val>, B<-nextprotoneg> I<val>
637 These flags enable the Enable the Application-Layer Protocol Negotiation
638 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
639 IETF standard and replaces NPN.
640 The I<val> list is a comma-separated list of supported protocol
641 names. The list should contain the most desirable protocols first.
642 Protocol names are printable ASCII strings, for example "http/1.1" or
644 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
646 =item B<-keylogfile> I<outfile>
648 Appends TLS secrets to the specified keylog file such that external programs
649 (like Wireshark) can decrypt TLS connections.
651 =item B<-max_early_data> I<int>
653 Change the default maximum early data bytes that are specified for new sessions
654 and any incoming early data (when used in conjunction with the B<-early_data>
655 flag). The default value is approximately 16k. The argument must be an integer
656 greater than or equal to 0.
660 Accept early data where possible. Cannot be used in conjunction with B<-www>,
661 B<-WWW>, B<-HTTP> or B<-rev>.
663 =item B<-anti_replay>, B<-no_anti_replay>
665 Switches replay protection on or off, respectively. Replay protection is on by
666 default unless overridden by a configuration file. When it is on, OpenSSL will
667 automatically detect if a session ticket has been used more than once, TLSv1.3
668 has been negotiated, and early data is enabled on the server. A full handshake
669 is forced if a session ticket is used a second or subsequent time. Any early
670 data that was sent will be rejected.
672 =item B<-http_server_binmode>
674 When acting as web-server (using option B<-WWW> or B<-HTTP>) open files requested
675 by the client in binary mode.
677 {- $OpenSSL::safe::opt_name_item -}
679 {- $OpenSSL::safe::opt_version_item -}
681 {- $OpenSSL::safe::opt_x_item -}
683 {- $OpenSSL::safe::opt_trust_item -}
685 {- $OpenSSL::safe::opt_r_item -}
687 {- $OpenSSL::safe::opt_engine_item -}
691 =head1 CONNECTED COMMANDS
693 If a connection request is established with an SSL client and neither the
694 B<-www> nor the B<-WWW> option has been used then normally any data received
695 from the client is displayed and any key presses will be sent to the client.
697 Certain commands are also recognized which perform special operations. These
698 commands are a letter which must appear at the start of a line. They are listed
705 End the current SSL connection but still accept new connections.
709 End the current SSL connection and exit.
713 Renegotiate the SSL session (TLSv1.2 and below only).
717 Renegotiate the SSL session and request a client certificate (TLSv1.2 and below
722 Send some plain text down the underlying TCP connection: this should
723 cause the client to disconnect due to a protocol violation.
727 Print out some session cache status information.
731 Send a key update message to the client (TLSv1.3 only)
735 Send a key update message to the client and request one back (TLSv1.3 only)
739 Send a certificate request to the client (TLSv1.3 only)
745 This command can be used to debug SSL clients. To accept connections
746 from a web browser the command:
748 openssl s_server -accept 443 -www
750 can be used for example.
752 Although specifying an empty list of CAs when requesting a client certificate
753 is strictly speaking a protocol violation, some SSL clients interpret this to
754 mean any CA is acceptable. This is useful for debugging purposes.
756 The session parameters can printed out using the L<openssl-sess_id(1)> command.
760 Because this program has a lot of options and also because some of the
761 techniques used are rather old, the C source for this command is rather
762 hard to read and not a model of how things should be done.
763 A typical SSL server program would be much simpler.
765 The output of common ciphers is wrong: it just gives the list of ciphers that
766 OpenSSL recognizes and the client supports.
768 There should be a way for this command to print out details
769 of any unknown cipher suites a client says it supports.
774 L<openssl-sess_id(1)>,
775 L<openssl-s_client(1)>,
776 L<openssl-ciphers(1)>,
778 L<SSL_CTX_set_max_send_fragment(3)>,
779 L<SSL_CTX_set_split_send_fragment(3)>,
780 L<SSL_CTX_set_max_pipelines(3)>,
781 L<ossl_store-file(7)>
785 The -no_alt_chains option was added in OpenSSL 1.1.0.
788 -allow-no-dhe-kex and -prioritize_chacha options were added in OpenSSL 1.1.1.
792 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
794 Licensed under the Apache License 2.0 (the "License"). You may not use
795 this file except in compliance with the License. You can obtain a copy
796 in the file LICENSE in the source distribution or at
797 L<https://www.openssl.org/source/license.html>.