xref: /minix3/crypto/external/bsd/openssl/dist/doc/apps/s_client.pod (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1ebfedea0SLionel Sambuc
2ebfedea0SLionel Sambuc=pod
3ebfedea0SLionel Sambuc
4ebfedea0SLionel Sambuc=head1 NAME
5ebfedea0SLionel Sambuc
6ebfedea0SLionel Sambucs_client - SSL/TLS client program
7ebfedea0SLionel Sambuc
8ebfedea0SLionel Sambuc=head1 SYNOPSIS
9ebfedea0SLionel Sambuc
10ebfedea0SLionel SambucB<openssl> B<s_client>
11ebfedea0SLionel Sambuc[B<-connect host:port>]
12*0a6a1f1dSLionel Sambuc[B<-servername name>]
13ebfedea0SLionel Sambuc[B<-verify depth>]
14*0a6a1f1dSLionel Sambuc[B<-verify_return_error>]
15ebfedea0SLionel Sambuc[B<-cert filename>]
16ebfedea0SLionel Sambuc[B<-certform DER|PEM>]
17ebfedea0SLionel Sambuc[B<-key filename>]
18ebfedea0SLionel Sambuc[B<-keyform DER|PEM>]
19ebfedea0SLionel Sambuc[B<-pass arg>]
20ebfedea0SLionel Sambuc[B<-CApath directory>]
21ebfedea0SLionel Sambuc[B<-CAfile filename>]
22*0a6a1f1dSLionel Sambuc[B<-no_alt_chains>]
23ebfedea0SLionel Sambuc[B<-reconnect>]
24ebfedea0SLionel Sambuc[B<-pause>]
25ebfedea0SLionel Sambuc[B<-showcerts>]
26ebfedea0SLionel Sambuc[B<-debug>]
27ebfedea0SLionel Sambuc[B<-msg>]
28ebfedea0SLionel Sambuc[B<-nbio_test>]
29ebfedea0SLionel Sambuc[B<-state>]
30ebfedea0SLionel Sambuc[B<-nbio>]
31ebfedea0SLionel Sambuc[B<-crlf>]
32ebfedea0SLionel Sambuc[B<-ign_eof>]
33*0a6a1f1dSLionel Sambuc[B<-no_ign_eof>]
34ebfedea0SLionel Sambuc[B<-quiet>]
35ebfedea0SLionel Sambuc[B<-ssl2>]
36ebfedea0SLionel Sambuc[B<-ssl3>]
37ebfedea0SLionel Sambuc[B<-tls1>]
38ebfedea0SLionel Sambuc[B<-no_ssl2>]
39ebfedea0SLionel Sambuc[B<-no_ssl3>]
40ebfedea0SLionel Sambuc[B<-no_tls1>]
41ebfedea0SLionel Sambuc[B<-bugs>]
42ebfedea0SLionel Sambuc[B<-cipher cipherlist>]
43*0a6a1f1dSLionel Sambuc[B<-serverpref>]
44ebfedea0SLionel Sambuc[B<-starttls protocol>]
45ebfedea0SLionel Sambuc[B<-engine id>]
46ebfedea0SLionel Sambuc[B<-tlsextdebug>]
47ebfedea0SLionel Sambuc[B<-no_ticket>]
48ebfedea0SLionel Sambuc[B<-sess_out filename>]
49ebfedea0SLionel Sambuc[B<-sess_in filename>]
50ebfedea0SLionel Sambuc[B<-rand file(s)>]
51*0a6a1f1dSLionel Sambuc[B<-status>]
52*0a6a1f1dSLionel Sambuc[B<-nextprotoneg protocols>]
53ebfedea0SLionel Sambuc
54ebfedea0SLionel Sambuc=head1 DESCRIPTION
55ebfedea0SLionel Sambuc
56ebfedea0SLionel SambucThe B<s_client> command implements a generic SSL/TLS client which connects
57ebfedea0SLionel Sambucto a remote host using SSL/TLS. It is a I<very> useful diagnostic tool for
58ebfedea0SLionel SambucSSL servers.
59ebfedea0SLionel Sambuc
60ebfedea0SLionel Sambuc=head1 OPTIONS
61ebfedea0SLionel Sambuc
62ebfedea0SLionel Sambuc=over 4
63ebfedea0SLionel Sambuc
64ebfedea0SLionel Sambuc=item B<-connect host:port>
65ebfedea0SLionel Sambuc
66ebfedea0SLionel SambucThis specifies the host and optional port to connect to. If not specified
67ebfedea0SLionel Sambucthen an attempt is made to connect to the local host on port 4433.
68ebfedea0SLionel Sambuc
69*0a6a1f1dSLionel Sambuc=item B<-servername name>
70*0a6a1f1dSLionel Sambuc
71*0a6a1f1dSLionel SambucSet the TLS SNI (Server Name Indication) extension in the ClientHello message.
72*0a6a1f1dSLionel Sambuc
73ebfedea0SLionel Sambuc=item B<-cert certname>
74ebfedea0SLionel Sambuc
75ebfedea0SLionel SambucThe certificate to use, if one is requested by the server. The default is
76ebfedea0SLionel Sambucnot to use a certificate.
77ebfedea0SLionel Sambuc
78ebfedea0SLionel Sambuc=item B<-certform format>
79ebfedea0SLionel Sambuc
80ebfedea0SLionel SambucThe certificate format to use: DER or PEM. PEM is the default.
81ebfedea0SLionel Sambuc
82ebfedea0SLionel Sambuc=item B<-key keyfile>
83ebfedea0SLionel Sambuc
84ebfedea0SLionel SambucThe private key to use. If not specified then the certificate file will
85ebfedea0SLionel Sambucbe used.
86ebfedea0SLionel Sambuc
87ebfedea0SLionel Sambuc=item B<-keyform format>
88ebfedea0SLionel Sambuc
89ebfedea0SLionel SambucThe private format to use: DER or PEM. PEM is the default.
90ebfedea0SLionel Sambuc
91ebfedea0SLionel Sambuc=item B<-pass arg>
92ebfedea0SLionel Sambuc
93ebfedea0SLionel Sambucthe private key password source. For more information about the format of B<arg>
94ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
95ebfedea0SLionel Sambuc
96ebfedea0SLionel Sambuc=item B<-verify depth>
97ebfedea0SLionel Sambuc
98ebfedea0SLionel SambucThe verify depth to use. This specifies the maximum length of the
99ebfedea0SLionel Sambucserver certificate chain and turns on server certificate verification.
100ebfedea0SLionel SambucCurrently the verify operation continues after errors so all the problems
101ebfedea0SLionel Sambucwith a certificate chain can be seen. As a side effect the connection
102ebfedea0SLionel Sambucwill never fail due to a server certificate verify failure.
103ebfedea0SLionel Sambuc
104*0a6a1f1dSLionel Sambuc=item B<-verify_return_error>
105*0a6a1f1dSLionel Sambuc
106*0a6a1f1dSLionel SambucReturn verification errors instead of continuing. This will typically
107*0a6a1f1dSLionel Sambucabort the handshake with a fatal error.
108*0a6a1f1dSLionel Sambuc
109ebfedea0SLionel Sambuc=item B<-CApath directory>
110ebfedea0SLionel Sambuc
111ebfedea0SLionel SambucThe directory to use for server certificate verification. This directory
112ebfedea0SLionel Sambucmust be in "hash format", see B<verify> for more information. These are
113ebfedea0SLionel Sambucalso used when building the client certificate chain.
114ebfedea0SLionel Sambuc
115ebfedea0SLionel Sambuc=item B<-CAfile file>
116ebfedea0SLionel Sambuc
117ebfedea0SLionel SambucA file containing trusted certificates to use during server authentication
118ebfedea0SLionel Sambucand to use when attempting to build the client certificate chain.
119ebfedea0SLionel Sambuc
120*0a6a1f1dSLionel Sambuc=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig -no_alt_chains>
121ebfedea0SLionel Sambuc
122ebfedea0SLionel SambucSet various certificate chain valiadition option. See the
123ebfedea0SLionel SambucL<B<verify>|verify(1)> manual page for details.
124ebfedea0SLionel Sambuc
125ebfedea0SLionel Sambuc=item B<-reconnect>
126ebfedea0SLionel Sambuc
127ebfedea0SLionel Sambucreconnects to the same server 5 times using the same session ID, this can
128ebfedea0SLionel Sambucbe used as a test that session caching is working.
129ebfedea0SLionel Sambuc
130ebfedea0SLionel Sambuc=item B<-pause>
131ebfedea0SLionel Sambuc
132ebfedea0SLionel Sambucpauses 1 second between each read and write call.
133ebfedea0SLionel Sambuc
134ebfedea0SLionel Sambuc=item B<-showcerts>
135ebfedea0SLionel Sambuc
136ebfedea0SLionel Sambucdisplay the whole server certificate chain: normally only the server
137ebfedea0SLionel Sambuccertificate itself is displayed.
138ebfedea0SLionel Sambuc
139ebfedea0SLionel Sambuc=item B<-prexit>
140ebfedea0SLionel Sambuc
141ebfedea0SLionel Sambucprint session information when the program exits. This will always attempt
142ebfedea0SLionel Sambucto print out information even if the connection fails. Normally information
143ebfedea0SLionel Sambucwill only be printed out once if the connection succeeds. This option is useful
144ebfedea0SLionel Sambucbecause the cipher in use may be renegotiated or the connection may fail
145ebfedea0SLionel Sambucbecause a client certificate is required or is requested only after an
146ebfedea0SLionel Sambucattempt is made to access a certain URL. Note: the output produced by this
147ebfedea0SLionel Sambucoption is not always accurate because a connection might never have been
148ebfedea0SLionel Sambucestablished.
149ebfedea0SLionel Sambuc
150ebfedea0SLionel Sambuc=item B<-state>
151ebfedea0SLionel Sambuc
152ebfedea0SLionel Sambucprints out the SSL session states.
153ebfedea0SLionel Sambuc
154ebfedea0SLionel Sambuc=item B<-debug>
155ebfedea0SLionel Sambuc
156ebfedea0SLionel Sambucprint extensive debugging information including a hex dump of all traffic.
157ebfedea0SLionel Sambuc
158ebfedea0SLionel Sambuc=item B<-msg>
159ebfedea0SLionel Sambuc
160ebfedea0SLionel Sambucshow all protocol messages with hex dump.
161ebfedea0SLionel Sambuc
162ebfedea0SLionel Sambuc=item B<-nbio_test>
163ebfedea0SLionel Sambuc
164ebfedea0SLionel Sambuctests non-blocking I/O
165ebfedea0SLionel Sambuc
166ebfedea0SLionel Sambuc=item B<-nbio>
167ebfedea0SLionel Sambuc
168ebfedea0SLionel Sambucturns on non-blocking I/O
169ebfedea0SLionel Sambuc
170ebfedea0SLionel Sambuc=item B<-crlf>
171ebfedea0SLionel Sambuc
172ebfedea0SLionel Sambucthis option translated a line feed from the terminal into CR+LF as required
173ebfedea0SLionel Sambucby some servers.
174ebfedea0SLionel Sambuc
175ebfedea0SLionel Sambuc=item B<-ign_eof>
176ebfedea0SLionel Sambuc
177ebfedea0SLionel Sambucinhibit shutting down the connection when end of file is reached in the
178ebfedea0SLionel Sambucinput.
179ebfedea0SLionel Sambuc
180ebfedea0SLionel Sambuc=item B<-quiet>
181ebfedea0SLionel Sambuc
182ebfedea0SLionel Sambucinhibit printing of session and certificate information.  This implicitly
183ebfedea0SLionel Sambucturns on B<-ign_eof> as well.
184ebfedea0SLionel Sambuc
185*0a6a1f1dSLionel Sambuc=item B<-no_ign_eof>
186*0a6a1f1dSLionel Sambuc
187*0a6a1f1dSLionel Sambucshut down the connection when end of file is reached in the input.
188*0a6a1f1dSLionel SambucCan be used to override the implicit B<-ign_eof> after B<-quiet>.
189*0a6a1f1dSLionel Sambuc
190ebfedea0SLionel Sambuc=item B<-psk_identity identity>
191ebfedea0SLionel Sambuc
192ebfedea0SLionel SambucUse the PSK identity B<identity> when using a PSK cipher suite.
193ebfedea0SLionel Sambuc
194ebfedea0SLionel Sambuc=item B<-psk key>
195ebfedea0SLionel Sambuc
196ebfedea0SLionel SambucUse the PSK key B<key> when using a PSK cipher suite. The key is
197ebfedea0SLionel Sambucgiven as a hexadecimal number without leading 0x, for example -psk
198ebfedea0SLionel Sambuc1a2b3c4d.
199ebfedea0SLionel Sambuc
200ebfedea0SLionel Sambuc=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
201ebfedea0SLionel Sambuc
202ebfedea0SLionel Sambucthese options disable the use of certain SSL or TLS protocols. By default
203ebfedea0SLionel Sambucthe initial handshake uses a method which should be compatible with all
204ebfedea0SLionel Sambucservers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
205ebfedea0SLionel Sambuc
206ebfedea0SLionel SambucUnfortunately there are a lot of ancient and broken servers in use which
207ebfedea0SLionel Sambuccannot handle this technique and will fail to connect. Some servers only
208ebfedea0SLionel Sambucwork if TLS is turned off with the B<-no_tls> option others will only
209ebfedea0SLionel Sambucsupport SSL v2 and may need the B<-ssl2> option.
210ebfedea0SLionel Sambuc
211ebfedea0SLionel Sambuc=item B<-bugs>
212ebfedea0SLionel Sambuc
213ebfedea0SLionel Sambucthere are several known bug in SSL and TLS implementations. Adding this
214ebfedea0SLionel Sambucoption enables various workarounds.
215ebfedea0SLionel Sambuc
216ebfedea0SLionel Sambuc=item B<-cipher cipherlist>
217ebfedea0SLionel Sambuc
218ebfedea0SLionel Sambucthis allows the cipher list sent by the client to be modified. Although
219ebfedea0SLionel Sambucthe server determines which cipher suite is used it should take the first
220ebfedea0SLionel Sambucsupported cipher in the list sent by the client. See the B<ciphers>
221ebfedea0SLionel Sambuccommand for more information.
222ebfedea0SLionel Sambuc
223*0a6a1f1dSLionel Sambuc=item B<-serverpref>
224*0a6a1f1dSLionel Sambuc
225*0a6a1f1dSLionel Sambucuse the server's cipher preferences; only used for SSLV2.
226*0a6a1f1dSLionel Sambuc
227ebfedea0SLionel Sambuc=item B<-starttls protocol>
228ebfedea0SLionel Sambuc
229ebfedea0SLionel Sambucsend the protocol-specific message(s) to switch to TLS for communication.
230ebfedea0SLionel SambucB<protocol> is a keyword for the intended protocol.  Currently, the only
231ebfedea0SLionel Sambucsupported keywords are "smtp", "pop3", "imap", and "ftp".
232ebfedea0SLionel Sambuc
233ebfedea0SLionel Sambuc=item B<-tlsextdebug>
234ebfedea0SLionel Sambuc
235ebfedea0SLionel Sambucprint out a hex dump of any TLS extensions received from the server.
236ebfedea0SLionel Sambuc
237ebfedea0SLionel Sambuc=item B<-no_ticket>
238ebfedea0SLionel Sambuc
239ebfedea0SLionel Sambucdisable RFC4507bis session ticket support.
240ebfedea0SLionel Sambuc
241ebfedea0SLionel Sambuc=item B<-sess_out filename>
242ebfedea0SLionel Sambuc
243ebfedea0SLionel Sambucoutput SSL session to B<filename>
244ebfedea0SLionel Sambuc
245ebfedea0SLionel Sambuc=item B<-sess_in sess.pem>
246ebfedea0SLionel Sambuc
247ebfedea0SLionel Sambucload SSL session from B<filename>. The client will attempt to resume a
248ebfedea0SLionel Sambucconnection from this session.
249ebfedea0SLionel Sambuc
250ebfedea0SLionel Sambuc=item B<-engine id>
251ebfedea0SLionel Sambuc
252ebfedea0SLionel Sambucspecifying an engine (by its unique B<id> string) will cause B<s_client>
253ebfedea0SLionel Sambucto attempt to obtain a functional reference to the specified engine,
254ebfedea0SLionel Sambucthus initialising it if needed. The engine will then be set as the default
255ebfedea0SLionel Sambucfor all available algorithms.
256ebfedea0SLionel Sambuc
257ebfedea0SLionel Sambuc=item B<-rand file(s)>
258ebfedea0SLionel Sambuc
259ebfedea0SLionel Sambuca file or files containing random data used to seed the random number
260ebfedea0SLionel Sambucgenerator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
261ebfedea0SLionel SambucMultiple files can be specified separated by a OS-dependent character.
262ebfedea0SLionel SambucThe separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
263ebfedea0SLionel Sambucall others.
264ebfedea0SLionel Sambuc
265*0a6a1f1dSLionel Sambuc=item B<-status>
266*0a6a1f1dSLionel Sambuc
267*0a6a1f1dSLionel Sambucsends a certificate status request to the server (OCSP stapling). The server
268*0a6a1f1dSLionel Sambucresponse (if any) is printed out.
269*0a6a1f1dSLionel Sambuc
270*0a6a1f1dSLionel Sambuc=item B<-nextprotoneg protocols>
271*0a6a1f1dSLionel Sambuc
272*0a6a1f1dSLionel Sambucenable Next Protocol Negotiation TLS extension and provide a list of
273*0a6a1f1dSLionel Sambuccomma-separated protocol names that the client should advertise
274*0a6a1f1dSLionel Sambucsupport for. The list should contain most wanted protocols first.
275*0a6a1f1dSLionel SambucProtocol names are printable ASCII strings, for example "http/1.1" or
276*0a6a1f1dSLionel Sambuc"spdy/3".
277*0a6a1f1dSLionel SambucEmpty list of protocols is treated specially and will cause the client to
278*0a6a1f1dSLionel Sambucadvertise support for the TLS extension but disconnect just after
279*0a6a1f1dSLionel Sambucreciving ServerHello with a list of server supported protocols.
280*0a6a1f1dSLionel Sambuc
281ebfedea0SLionel Sambuc=back
282ebfedea0SLionel Sambuc
283ebfedea0SLionel Sambuc=head1 CONNECTED COMMANDS
284ebfedea0SLionel Sambuc
285ebfedea0SLionel SambucIf a connection is established with an SSL server then any data received
286ebfedea0SLionel Sambucfrom the server is displayed and any key presses will be sent to the
287ebfedea0SLionel Sambucserver. When used interactively (which means neither B<-quiet> nor B<-ign_eof>
288ebfedea0SLionel Sambuchave been given), the session will be renegotiated if the line begins with an
289ebfedea0SLionel SambucB<R>, and if the line begins with a B<Q> or if end of file is reached, the
290ebfedea0SLionel Sambucconnection will be closed down.
291ebfedea0SLionel Sambuc
292ebfedea0SLionel Sambuc=head1 NOTES
293ebfedea0SLionel Sambuc
294ebfedea0SLionel SambucB<s_client> can be used to debug SSL servers. To connect to an SSL HTTP
295ebfedea0SLionel Sambucserver the command:
296ebfedea0SLionel Sambuc
297ebfedea0SLionel Sambuc openssl s_client -connect servername:443
298ebfedea0SLionel Sambuc
299ebfedea0SLionel Sambucwould typically be used (https uses port 443). If the connection succeeds
300ebfedea0SLionel Sambucthen an HTTP command can be given such as "GET /" to retrieve a web page.
301ebfedea0SLionel Sambuc
302ebfedea0SLionel SambucIf the handshake fails then there are several possible causes, if it is
303ebfedea0SLionel Sambucnothing obvious like no client certificate then the B<-bugs>, B<-ssl2>,
304ebfedea0SLionel SambucB<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> options can be tried
305ebfedea0SLionel Sambucin case it is a buggy server. In particular you should play with these
306ebfedea0SLionel Sambucoptions B<before> submitting a bug report to an OpenSSL mailing list.
307ebfedea0SLionel Sambuc
308ebfedea0SLionel SambucA frequent problem when attempting to get client certificates working
309ebfedea0SLionel Sambucis that a web client complains it has no certificates or gives an empty
310ebfedea0SLionel Sambuclist to choose from. This is normally because the server is not sending
311ebfedea0SLionel Sambucthe clients certificate authority in its "acceptable CA list" when it
312ebfedea0SLionel Sambucrequests a certificate. By using B<s_client> the CA list can be viewed
313ebfedea0SLionel Sambucand checked. However some servers only request client authentication
314ebfedea0SLionel Sambucafter a specific URL is requested. To obtain the list in this case it
315ebfedea0SLionel Sambucis necessary to use the B<-prexit> option and send an HTTP request
316ebfedea0SLionel Sambucfor an appropriate page.
317ebfedea0SLionel Sambuc
318ebfedea0SLionel SambucIf a certificate is specified on the command line using the B<-cert>
319ebfedea0SLionel Sambucoption it will not be used unless the server specifically requests
320ebfedea0SLionel Sambuca client certificate. Therefor merely including a client certificate
321ebfedea0SLionel Sambucon the command line is no guarantee that the certificate works.
322ebfedea0SLionel Sambuc
323ebfedea0SLionel SambucIf there are problems verifying a server certificate then the
324ebfedea0SLionel SambucB<-showcerts> option can be used to show the whole chain.
325ebfedea0SLionel Sambuc
326ebfedea0SLionel SambucSince the SSLv23 client hello cannot include compression methods or extensions
327ebfedea0SLionel Sambucthese will only be supported if its use is disabled, for example by using the
328ebfedea0SLionel SambucB<-no_sslv2> option.
329ebfedea0SLionel Sambuc
330*0a6a1f1dSLionel SambucThe B<s_client> utility is a test tool and is designed to continue the
331*0a6a1f1dSLionel Sambuchandshake after any certificate verification errors. As a result it will
332*0a6a1f1dSLionel Sambucaccept any certificate chain (trusted or not) sent by the peer. None test
333*0a6a1f1dSLionel Sambucapplications should B<not> do this as it makes them vulnerable to a MITM
334*0a6a1f1dSLionel Sambucattack. This behaviour can be changed by with the B<-verify_return_error>
335*0a6a1f1dSLionel Sambucoption: any verify errors are then returned aborting the handshake.
336*0a6a1f1dSLionel Sambuc
337ebfedea0SLionel Sambuc=head1 BUGS
338ebfedea0SLionel Sambuc
339ebfedea0SLionel SambucBecause this program has a lot of options and also because some of
340ebfedea0SLionel Sambucthe techniques used are rather old, the C source of s_client is rather
341ebfedea0SLionel Sambuchard to read and not a model of how things should be done. A typical
342ebfedea0SLionel SambucSSL client program would be much simpler.
343ebfedea0SLionel Sambuc
344ebfedea0SLionel SambucThe B<-prexit> option is a bit of a hack. We should really report
345ebfedea0SLionel Sambucinformation whenever a session is renegotiated.
346ebfedea0SLionel Sambuc
347ebfedea0SLionel Sambuc=head1 SEE ALSO
348ebfedea0SLionel Sambuc
349ebfedea0SLionel SambucL<sess_id(1)|sess_id(1)>, L<s_server(1)|s_server(1)>, L<ciphers(1)|ciphers(1)>
350ebfedea0SLionel Sambuc
351*0a6a1f1dSLionel Sambuc=head1 HISTORY
352*0a6a1f1dSLionel Sambuc
353*0a6a1f1dSLionel SambucThe -no_alt_chains options was first added to OpenSSL 1.0.1n and 1.0.2b.
354*0a6a1f1dSLionel Sambuc
355ebfedea0SLionel Sambuc=cut
356