2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-s_client - SSL/TLS client program
10 B<openssl> B<s_client>
12 [B<-connect> I<host:port>]
13 [B<-bind> I<host:port>]
14 [B<-proxy> I<host:port>]
15 [B<-proxy_user> I<userid>]
16 [B<-proxy_pass> I<arg>]
20 [B<-servername> I<name>]
23 [B<-verify_return_error>]
24 [B<-cert> I<filename>]
25 [B<-certform> B<DER>|B<PEM>]
26 [B<-CRLform> B<DER>|B<PEM>]
28 [B<-keyform> B<DER>|B<PEM>]
29 [B<-cert_chain> I<filename>]
32 [B<-chainCApath> I<directory>]
33 [B<-chainCAfile> I<filename>]
34 [B<-chainCAstore> I<uri>]
35 [B<-requestCAfile> I<filename>]
36 [B<-dane_tlsa_domain> I<domain>]
37 [B<-dane_tlsa_rrdata> I<rrdata>]
38 [B<-dane_ee_no_namechecks>]
50 [B<-psk_identity> I<identity>]
52 [B<-psk_session> I<file>]
65 [B<-allow_no_dhe_kex>]
66 [B<-sigalgs> I<sigalglist>]
67 [B<-curves> I<curvelist>]
68 [B<-cipher> I<cipherlist>]
69 [B<-ciphersuites> I<val>]
71 [B<-starttls> I<protocol>]
72 [B<-xmpphost> I<hostname>]
73 [B<-name> I<hostname>]
76 [B<-sess_out> I<filename>]
77 [B<-sess_in> I<filename>]
78 [B<-serverinfo> I<types>]
80 [B<-alpn> I<protocols>]
81 [B<-nextprotoneg> I<protocols>]
85 [B<-keylogfile> I<file>]
86 [B<-early_data> I<file>]
88 {- $OpenSSL::safe::opt_name_synopsis -}
89 {- $OpenSSL::safe::opt_version_synopsis -}
90 {- $OpenSSL::safe::opt_x_synopsis -}
91 {- $OpenSSL::safe::opt_trust_synopsis -}
92 {- $OpenSSL::safe::opt_r_synopsis -}
93 {- $OpenSSL::safe::opt_engine_synopsis -}
94 {- $OpenSSL::safe::opt_v_synopsis -}
97 =for openssl ifdef engine ssl_client_engine ct noct ctlogfile
99 =for openssl ifdef ssl3 unix 4 6 use_srtp status trace wdebug nextprotoneg
101 =for openssl ifdef ssl3 tls1 tls1_1 tls1_2 tls1_3 dtls mtu dtls1 dtls1_2
103 =for openssl ifdef sctp_label_bug sctp
105 =for openssl ifdef srpuser srppass srp_lateuser srp_moregroups srp_strength
109 This command implements a generic SSL/TLS client which
110 connects to a remote host using SSL/TLS. It is a I<very> useful diagnostic
111 tool for SSL servers.
115 In addition to the options below, this command also supports the
116 common and client only options documented
117 in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
124 Print out a usage message.
126 =item B<-connect> I<host>:I<port>
128 This specifies the host and optional port to connect to. It is possible to
129 select the host and port using the optional target positional argument instead.
130 If neither this nor the target positional argument are specified then an attempt
131 is made to connect to the local host on port 4433.
133 =item B<-bind> I<host:port>
135 This specifies the host address and or port to bind as the source for the
136 connection. For Unix-domain sockets the port is ignored and the host is
137 used as the source socket address.
139 =item B<-proxy> I<host:port>
141 When used with the B<-connect> flag, the program uses the host and port
142 specified with this flag and issues an HTTP CONNECT command to connect
143 to the desired server.
145 =item B<-proxy_user> I<userid>
147 When used with the B<-proxy> flag, the program will attempt to authenticate
148 with the specified proxy using basic (base64) authentication.
149 NB: Basic authentication is insecure; the credentials are sent to the proxy
150 in easily reversible base64 encoding before any TLS/SSL session is established.
151 Therefore these credentials are easily recovered by anyone able to sniff/trace
152 the network. Use with caution.
154 =item B<-proxy_pass> I<arg>
156 The proxy password source, used with the B<-proxy_user> flag.
157 For more information about the format of B<arg>
158 see L<openssl(1)/Pass Phrase Options>.
160 =item B<-unix> I<path>
162 Connect over the specified Unix-domain socket.
172 =item B<-servername> I<name>
174 Set the TLS SNI (Server Name Indication) extension in the ClientHello message to
176 If B<-servername> is not provided, the TLS SNI extension will be populated with
177 the name given to B<-connect> if it follows a DNS name format. If B<-connect> is
178 not provided either, the SNI is set to "localhost".
179 This is the default since OpenSSL 1.1.1.
181 Even though SNI should normally be a DNS name and not an IP address, if
182 B<-servername> is provided then that name will be sent, regardless of whether
183 it is a DNS name or not.
185 This option cannot be used in conjunction with B<-noservername>.
187 =item B<-noservername>
189 Suppresses sending of the SNI (Server Name Indication) extension in the
190 ClientHello message. Cannot be used in conjunction with the B<-servername> or
191 <-dane_tlsa_domain> options.
193 =item B<-cert> I<certname>
195 The certificate to use, if one is requested by the server. The default is
196 not to use a certificate.
198 =item B<-certform> I<format>
200 The certificate format to use: DER or PEM. PEM is the default.
202 =item B<-CRLform> B<DER>|B<PEM>
204 The CRL format; the default is B<PEM>.
205 See L<openssl(1)/Format Options> for details.
207 =item B<-key> I<keyfile>
209 The private key to use. If not specified then the certificate file will
212 =item B<-keyform> I<format>
214 The key format; the default is B<PEM>.
215 See L<openssl(1)/Format Options> for details.
219 A file containing trusted certificates to use when attempting to build the
220 client/server certificate chain related to the certificate specified via the
223 =item B<-build_chain>
225 Specify whether the application should build the certificate chain to be
226 provided to the server.
228 =item B<-pass> I<arg>
230 the private key password source. For more information about the format of I<arg>
231 see L<openssl(1)/Pass phrase options>.
233 =item B<-verify> I<depth>
235 The verify depth to use. This specifies the maximum length of the
236 server certificate chain and turns on server certificate verification.
237 Currently the verify operation continues after errors so all the problems
238 with a certificate chain can be seen. As a side effect the connection
239 will never fail due to a server certificate verify failure.
241 =item B<-verify_return_error>
243 Return verification errors instead of continuing. This will typically
244 abort the handshake with a fatal error.
246 =item B<-chainCApath> I<directory>
248 The directory to use for building the chain provided to the server. This
249 directory must be in "hash format", see L<openssl-verify(1)> for more
252 =item B<-chainCAfile> I<file>
254 A file containing trusted certificates to use when attempting to build the
255 client certificate chain.
257 =item B<-chainCAstore> I<uri>
259 The URI to use when attempting to build the client certificate chain.
261 =item B<-requestCAfile> I<file>
263 A file containing a list of certificates whose subject names will be sent
264 to the server in the B<certificate_authorities> extension. Only supported
267 =item B<-dane_tlsa_domain> I<domain>
269 Enable RFC6698/RFC7671 DANE TLSA authentication and specify the
270 TLSA base domain which becomes the default SNI hint and the primary
271 reference identifier for hostname checks. This must be used in
272 combination with at least one instance of the B<-dane_tlsa_rrdata>
275 When DANE authentication succeeds, the diagnostic output will include
276 the lowest (closest to 0) depth at which a TLSA record authenticated
277 a chain certificate. When that TLSA record is a "2 1 0" trust
278 anchor public key that signed (rather than matched) the top-most
279 certificate of the chain, the result is reported as "TA public key
280 verified". Otherwise, either the TLSA record "matched TA certificate"
281 at a positive depth or else "matched EE certificate" at depth 0.
283 =item B<-dane_tlsa_rrdata> I<rrdata>
285 Use one or more times to specify the RRDATA fields of the DANE TLSA
286 RRset associated with the target service. The I<rrdata> value is
287 specied in "presentation form", that is four whitespace separated
288 fields that specify the usage, selector, matching type and associated
289 data, with the last of these encoded in hexadecimal. Optional
290 whitespace is ignored in the associated data field. For example:
292 $ openssl s_client -brief -starttls smtp \
293 -connect smtp.example.com:25 \
294 -dane_tlsa_domain smtp.example.com \
295 -dane_tlsa_rrdata "2 1 1
296 B111DD8A1C2091A89BD4FD60C57F0716CCE50FEEFF8137CDBEE0326E 02CF362B" \
297 -dane_tlsa_rrdata "2 1 1
298 60B87575447DCBA2A36B7D11AC09FB24A9DB406FEE12D2CC90180517 616E8A18"
301 Verified peername: smtp.example.com
302 DANE TLSA 2 1 1 ...ee12d2cc90180517616e8a18 matched TA certificate at depth 1
305 =item B<-dane_ee_no_namechecks>
307 This disables server name checks when authenticating via DANE-EE(3) TLSA
309 For some applications, primarily web browsers, it is not safe to disable name
310 checks due to "unknown key share" attacks, in which a malicious server can
311 convince a client that a connection to a victim server is instead a secure
312 connection to the malicious server.
313 The malicious server may then be able to violate cross-origin scripting
315 Thus, despite the text of RFC7671, name checks are by default enabled for
316 DANE-EE(3) TLSA records, and can be disabled in applications where it is safe
318 In particular, SMTP and XMPP clients should set this option as SRV and MX
319 records already make it possible for a remote domain to redirect client
320 connections to any server of its choice, and in any case SMTP and XMPP clients
321 do not execute scripts downloaded from remote servers.
325 Reconnects to the same server 5 times using the same session ID, this can
326 be used as a test that session caching is working.
330 Displays the server certificate list as sent by the server: it only consists of
331 certificates the server has sent (in the order the server has sent them). It is
332 B<not> a verified chain.
336 Print session information when the program exits. This will always attempt
337 to print out information even if the connection fails. Normally information
338 will only be printed out once if the connection succeeds. This option is useful
339 because the cipher in use may be renegotiated or the connection may fail
340 because a client certificate is required or is requested only after an
341 attempt is made to access a certain URL. Note: the output produced by this
342 option is not always accurate because a connection might never have been
347 Prints out the SSL session states.
351 Print extensive debugging information including a hex dump of all traffic.
355 Show all protocol messages with hex dump.
359 Show verbose trace output of protocol messages. OpenSSL needs to be compiled
360 with B<enable-ssl-trace> for this option to work.
364 File to send output of B<-msg> or B<-trace> to, default standard output.
368 Tests non-blocking I/O
372 Turns on non-blocking I/O
376 This option translated a line feed from the terminal into CR+LF as required
381 Inhibit shutting down the connection when end of file is reached in the
386 Inhibit printing of session and certificate information. This implicitly
387 turns on B<-ign_eof> as well.
391 Shut down the connection when end of file is reached in the input.
392 Can be used to override the implicit B<-ign_eof> after B<-quiet>.
394 =item B<-psk_identity> I<identity>
396 Use the PSK identity I<identity> when using a PSK cipher suite.
397 The default value is "Client_identity" (without the quotes).
401 Use the PSK key I<key> when using a PSK cipher suite. The key is
402 given as a hexadecimal number without leading 0x, for example -psk
404 This option must be provided in order to use a PSK cipher.
406 =item B<-psk_session> I<file>
408 Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
409 Note that this will only work if TLSv1.3 is negotiated.
413 Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
414 conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
415 available where OpenSSL has support for SCTP enabled.
417 =item B<-sctp_label_bug>
419 Use the incorrect behaviour of older OpenSSL implementations when computing
420 endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
421 older broken implementations but breaks interoperability with correct
422 implementations. Must be used in conjunction with B<-sctp>. This option is only
423 available where OpenSSL has support for SCTP enabled.
425 =item B<-fallback_scsv>
427 Send TLS_FALLBACK_SCSV in the ClientHello.
431 Switch on asynchronous mode. Cryptographic operations will be performed
432 asynchronously. This will only have an effect if an asynchronous capable engine
433 is also used via the B<-engine> option. For test purposes the dummy async engine
434 (dasync) can be used (if available).
436 =item B<-max_send_frag> I<int>
438 The maximum size of data fragment to send.
439 See L<SSL_CTX_set_max_send_fragment(3)> for further information.
441 =item B<-split_send_frag> I<int>
443 The size used to split data for encrypt pipelines. If more data is written in
444 one go than this value then it will be split into multiple pipelines, up to the
445 maximum number of pipelines defined by max_pipelines. This only has an effect if
446 a suitable cipher suite has been negotiated, an engine that supports pipelining
447 has been loaded, and max_pipelines is greater than 1. See
448 L<SSL_CTX_set_split_send_fragment(3)> for further information.
450 =item B<-max_pipelines> I<int>
452 The maximum number of encrypt/decrypt pipelines to be used. This will only have
453 an effect if an engine has been loaded that supports pipelining (e.g. the dasync
454 engine) and a suitable cipher suite has been negotiated. The default value is 1.
455 See L<SSL_CTX_set_max_pipelines(3)> for further information.
457 =item B<-read_buf> I<int>
459 The default read buffer size to be used for connections. This will only have an
460 effect if the buffer size is larger than the size that would otherwise be used
461 and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
462 further information).
466 There are several known bugs in SSL and TLS implementations. Adding this
467 option enables various workarounds.
471 Enables support for SSL/TLS compression.
472 This option was introduced in OpenSSL 1.1.0.
473 TLS compression is not recommended and is off by default as of
478 Disables support for SSL/TLS compression.
479 TLS compression is not recommended and is off by default as of
484 Only provide a brief summary of connection parameters instead of the
485 normal verbose output.
487 =item B<-sigalgs> I<sigalglist>
489 Specifies the list of signature algorithms that are sent by the client.
490 The server selects one entry in the list based on its preferences.
491 For example strings, see L<SSL_CTX_set1_sigalgs(3)>
493 =item B<-curves> I<curvelist>
495 Specifies the list of supported curves to be sent by the client. The curve is
496 ultimately selected by the server. For a list of all curves, use:
498 $ openssl ecparam -list_curves
500 =item B<-cipher> I<cipherlist>
502 This allows the TLSv1.2 and below cipher list sent by the client to be modified.
503 This list will be combined with any TLSv1.3 ciphersuites that have been
504 configured. Although the server determines which ciphersuite is used it should
505 take the first supported cipher in the list sent by the client. See
506 L<openssl-ciphers(1)> for more information.
508 =item B<-ciphersuites> I<val>
510 This allows the TLSv1.3 ciphersuites sent by the client to be modified. This
511 list will be combined with any TLSv1.2 and below ciphersuites that have been
512 configured. Although the server determines which cipher suite is used it should
513 take the first supported cipher in the list sent by the client. See
514 L<openssl-ciphers(1)> for more information. The format for this list is a simple
515 colon (":") separated list of TLSv1.3 ciphersuite names.
517 =item B<-starttls> I<protocol>
519 Send the protocol-specific message(s) to switch to TLS for communication.
520 I<protocol> is a keyword for the intended protocol. Currently, the only
521 supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server",
522 "irc", "postgres", "mysql", "lmtp", "nntp", "sieve" and "ldap".
524 =item B<-xmpphost> I<hostname>
526 This option, when used with "-starttls xmpp" or "-starttls xmpp-server",
527 specifies the host for the "to" attribute of the stream element.
528 If this option is not specified, then the host specified with "-connect"
531 This option is an alias of the B<-name> option for "xmpp" and "xmpp-server".
533 =item B<-name> I<hostname>
535 This option is used to specify hostname information for various protocols
536 used with B<-starttls> option. Currently only "xmpp", "xmpp-server",
537 "smtp" and "lmtp" can utilize this B<-name> option.
539 If this option is used with "-starttls xmpp" or "-starttls xmpp-server",
540 if specifies the host for the "to" attribute of the stream element. If this
541 option is not specified, then the host specified with "-connect" will be used.
543 If this option is used with "-starttls lmtp" or "-starttls smtp", it specifies
544 the name to use in the "LMTP LHLO" or "SMTP EHLO" message, respectively. If
545 this option is not specified, then "mail.example.com" will be used.
547 =item B<-tlsextdebug>
549 Print out a hex dump of any TLS extensions received from the server.
553 Disable RFC4507bis session ticket support.
555 =item B<-sess_out> I<filename>
557 Output SSL session to I<filename>.
559 =item B<-sess_in> I<filename>
561 Load SSL session from I<filename>. The client will attempt to resume a
562 connection from this session.
564 =item B<-serverinfo> I<types>
566 A list of comma-separated TLS Extension Types (numbers between 0 and
567 65535). Each type will be sent as an empty ClientHello TLS Extension.
568 The server's response (if any) will be encoded and displayed as a PEM
573 Sends a certificate status request to the server (OCSP stapling). The server
574 response (if any) is printed out.
576 =item B<-alpn> I<protocols>, B<-nextprotoneg> I<protocols>
578 These flags enable the Enable the Application-Layer Protocol Negotiation
579 or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
580 IETF standard and replaces NPN.
581 The I<protocols> list is a comma-separated list of protocol names that
582 the client should advertise support for. The list should contain the most
583 desirable protocols first. Protocol names are printable ASCII strings,
584 for example "http/1.1" or "spdy/3".
585 An empty list of protocols is treated specially and will cause the
586 client to advertise support for the TLS extension but disconnect just
587 after receiving ServerHello with a list of server supported protocols.
588 The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
590 =item B<-ct>, B<-noct>
592 Use one of these two options to control whether Certificate Transparency (CT)
593 is enabled (B<-ct>) or disabled (B<-noct>).
594 If CT is enabled, signed certificate timestamps (SCTs) will be requested from
595 the server and reported at handshake completion.
597 Enabling CT also enables OCSP stapling, as this is one possible delivery method
602 A file containing a list of known Certificate Transparency logs. See
603 L<SSL_CTX_set_ctlog_list_file(3)> for the expected file format.
605 =item B<-keylogfile> I<file>
607 Appends TLS secrets to the specified keylog file such that external programs
608 (like Wireshark) can decrypt TLS connections.
610 =item B<-early_data> I<file>
612 Reads the contents of the specified file and attempts to send it as early data
613 to the server. This will only work with resumed sessions that support early
614 data and when the server accepts the early data.
618 For TLSv1.3 only, send the Post-Handshake Authentication extension. This will
619 happen whether or not a certificate has been provided via B<-cert>.
621 {- $OpenSSL::safe::opt_version_item -}
623 {- $OpenSSL::safe::opt_name_item -}
625 {- $OpenSSL::safe::opt_x_item -}
627 {- $OpenSSL::safe::opt_trust_item -}
629 {- $OpenSSL::safe::opt_r_item -}
631 {- $OpenSSL::safe::opt_engine_item -}
633 {- $OpenSSL::safe::opt_v_item -}
635 Verification errors are displayed, for debugging, but the command will
636 proceed unless the B<-verify_return_error> option is used.
638 =item I<host>:I<port>
640 Rather than providing B<-connect>, the target hostname and optional port may
641 be provided as a single positional argument after all options. If neither this
642 nor B<-connect> are provided, falls back to attempting to connect to
643 I<localhost> on port I<4433>.
647 =head1 CONNECTED COMMANDS
649 If a connection is established with an SSL server then any data received
650 from the server is displayed and any key presses will be sent to the
651 server. If end of file is reached then the connection will be closed down. When
652 used interactively (which means neither B<-quiet> nor B<-ign_eof> have been
653 given), then certain commands are also recognized which perform special
654 operations. These commands are a letter which must appear at the start of a
655 line. They are listed below.
661 End the current SSL connection and exit.
665 Renegotiate the SSL session (TLSv1.2 and below only).
669 Send a key update message to the server (TLSv1.3 only)
673 Send a key update message to the server and request one back (TLSv1.3 only)
679 This command can be used to debug SSL servers. To connect to an SSL HTTP
682 openssl s_client -connect servername:443
684 would typically be used (https uses port 443). If the connection succeeds
685 then an HTTP command can be given such as "GET /" to retrieve a web page.
687 If the handshake fails then there are several possible causes, if it is
688 nothing obvious like no client certificate then the B<-bugs>,
689 B<-ssl3>, B<-tls1>, B<-no_ssl3>, B<-no_tls1> options can be tried
690 in case it is a buggy server. In particular you should play with these
691 options B<before> submitting a bug report to an OpenSSL mailing list.
693 A frequent problem when attempting to get client certificates working
694 is that a web client complains it has no certificates or gives an empty
695 list to choose from. This is normally because the server is not sending
696 the clients certificate authority in its "acceptable CA list" when it
697 requests a certificate. By using this command, the CA list can be viewed
698 and checked. However some servers only request client authentication
699 after a specific URL is requested. To obtain the list in this case it
700 is necessary to use the B<-prexit> option and send an HTTP request
701 for an appropriate page.
703 If a certificate is specified on the command line using the B<-cert>
704 option it will not be used unless the server specifically requests
705 a client certificate. Therefor merely including a client certificate
706 on the command line is no guarantee that the certificate works.
708 If there are problems verifying a server certificate then the
709 B<-showcerts> option can be used to show all the certificates sent by the
712 This command is a test tool and is designed to continue the
713 handshake after any certificate verification errors. As a result it will
714 accept any certificate chain (trusted or not) sent by the peer. None test
715 applications should B<not> do this as it makes them vulnerable to a MITM
716 attack. This behaviour can be changed by with the B<-verify_return_error>
717 option: any verify errors are then returned aborting the handshake.
719 The B<-bind> option may be useful if the server or a firewall requires
720 connections to come from some particular address and or port.
724 Because this program has a lot of options and also because some of the
725 techniques used are rather old, the C source for this command is rather
726 hard to read and not a model of how things should be done.
727 A typical SSL client program would be much simpler.
729 The B<-prexit> option is a bit of a hack. We should really report
730 information whenever a session is renegotiated.
735 L<openssl-sess_id(1)>,
736 L<openssl-s_server(1)>,
737 L<openssl-ciphers(1)>,
739 L<SSL_CTX_set_max_send_fragment(3)>,
740 L<SSL_CTX_set_split_send_fragment(3)>,
741 L<SSL_CTX_set_max_pipelines(3)>,
742 L<ossl_store-file(7)>
746 The B<-no_alt_chains> option was added in OpenSSL 1.1.0.
747 The B<-name> option was added in OpenSSL 1.1.1.
751 Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
753 Licensed under the Apache License 2.0 (the "License"). You may not use
754 this file except in compliance with the License. You can obtain a copy
755 in the file LICENSE in the source distribution or at
756 L<https://www.openssl.org/source/license.html>.