s_client.pod 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. =pod
  2. =head1 NAME
  3. s_client - SSL/TLS client program
  4. =head1 SYNOPSIS
  5. B<openssl> B<s_client>
  6. [B<-connect host:port>]
  7. [B<-verify depth>]
  8. [B<-cert filename>]
  9. [B<-certform DER|PEM>]
  10. [B<-key filename>]
  11. [B<-keyform DER|PEM>]
  12. [B<-pass arg>]
  13. [B<-CApath directory>]
  14. [B<-CAfile filename>]
  15. [B<-attime timestamp>]
  16. [B<-check_ss_sig>]
  17. [B<-crl_check>]
  18. [B<-crl_check_all>]
  19. [B<-explicit_policy>]
  20. [B<-ignore_critical>]
  21. [B<-inhibit_any>]
  22. [B<-inhibit_map>]
  23. [B<-issuer_checks>]
  24. [B<-policy arg>]
  25. [B<-policy_check>]
  26. [B<-policy_print>]
  27. [B<-purpose purpose>]
  28. [B<-use_deltas>]
  29. [B<-verify_depth num>]
  30. [B<-x509_strict>]
  31. [B<-reconnect>]
  32. [B<-pause>]
  33. [B<-showcerts>]
  34. [B<-debug>]
  35. [B<-msg>]
  36. [B<-nbio_test>]
  37. [B<-state>]
  38. [B<-nbio>]
  39. [B<-crlf>]
  40. [B<-ign_eof>]
  41. [B<-quiet>]
  42. [B<-ssl2>]
  43. [B<-ssl3>]
  44. [B<-tls1>]
  45. [B<-no_ssl2>]
  46. [B<-no_ssl3>]
  47. [B<-no_tls1>]
  48. [B<-fallback_scsv>]
  49. [B<-bugs>]
  50. [B<-cipher cipherlist>]
  51. [B<-starttls protocol>]
  52. [B<-xmpphost hostname>]
  53. [B<-engine id>]
  54. [B<-tlsextdebug>]
  55. [B<-no_ticket>]
  56. [B<-sess_out filename>]
  57. [B<-sess_in filename>]
  58. [B<-rand file(s)>]
  59. =head1 DESCRIPTION
  60. The B<s_client> command implements a generic SSL/TLS client which connects
  61. to a remote host using SSL/TLS. It is a I<very> useful diagnostic tool for
  62. SSL servers.
  63. =head1 OPTIONS
  64. In addition to the options below the B<s_client> utility also supports the
  65. common and client only options documented in the
  66. in the L<SSL_CONF_cmd(3)|SSL_CONF_cmd(3)/SUPPORTED COMMAND LINE COMMANDS>
  67. manual page.
  68. =over 4
  69. =item B<-connect host:port>
  70. This specifies the host and optional port to connect to. If not specified
  71. then an attempt is made to connect to the local host on port 4433.
  72. =item B<-cert certname>
  73. The certificate to use, if one is requested by the server. The default is
  74. not to use a certificate.
  75. =item B<-certform format>
  76. The certificate format to use: DER or PEM. PEM is the default.
  77. =item B<-key keyfile>
  78. The private key to use. If not specified then the certificate file will
  79. be used.
  80. =item B<-keyform format>
  81. The private format to use: DER or PEM. PEM is the default.
  82. =item B<-pass arg>
  83. the private key password source. For more information about the format of B<arg>
  84. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
  85. =item B<-verify depth>
  86. The verify depth to use. This specifies the maximum length of the
  87. server certificate chain and turns on server certificate verification.
  88. Currently the verify operation continues after errors so all the problems
  89. with a certificate chain can be seen. As a side effect the connection
  90. will never fail due to a server certificate verify failure.
  91. =item B<-CApath directory>
  92. The directory to use for server certificate verification. This directory
  93. must be in "hash format", see B<verify> for more information. These are
  94. also used when building the client certificate chain.
  95. =item B<-CAfile file>
  96. A file containing trusted certificates to use during server authentication
  97. and to use when attempting to build the client certificate chain.
  98. =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
  99. B<explicit_policy>, B<-ignore_critical>, B<-inhibit_any>,
  100. B<-inhibit_map>, B<-issuer_checks>, B<-policy>,
  101. B<-policy_check>, B<-policy_print>, B<-purpose>,
  102. B<-use_deltas>, B<-verify_depth>, B<-x509_strict>
  103. Set various certificate chain valiadition options. See the
  104. L<B<verify>|verify(1)> manual page for details.
  105. =item B<-reconnect>
  106. reconnects to the same server 5 times using the same session ID, this can
  107. be used as a test that session caching is working.
  108. =item B<-pause>
  109. pauses 1 second between each read and write call.
  110. =item B<-showcerts>
  111. display the whole server certificate chain: normally only the server
  112. certificate itself is displayed.
  113. =item B<-prexit>
  114. print session information when the program exits. This will always attempt
  115. to print out information even if the connection fails. Normally information
  116. will only be printed out once if the connection succeeds. This option is useful
  117. because the cipher in use may be renegotiated or the connection may fail
  118. because a client certificate is required or is requested only after an
  119. attempt is made to access a certain URL. Note: the output produced by this
  120. option is not always accurate because a connection might never have been
  121. established.
  122. =item B<-state>
  123. prints out the SSL session states.
  124. =item B<-debug>
  125. print extensive debugging information including a hex dump of all traffic.
  126. =item B<-msg>
  127. show all protocol messages with hex dump.
  128. =item B<-nbio_test>
  129. tests non-blocking I/O
  130. =item B<-nbio>
  131. turns on non-blocking I/O
  132. =item B<-crlf>
  133. this option translated a line feed from the terminal into CR+LF as required
  134. by some servers.
  135. =item B<-ign_eof>
  136. inhibit shutting down the connection when end of file is reached in the
  137. input.
  138. =item B<-quiet>
  139. inhibit printing of session and certificate information. This implicitly
  140. turns on B<-ign_eof> as well.
  141. =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
  142. these options disable the use of certain SSL or TLS protocols. By default
  143. the initial handshake uses a method which should be compatible with all
  144. servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
  145. Unfortunately there are still ancient and broken servers in use which
  146. cannot handle this technique and will fail to connect. Some servers only
  147. work if TLS is turned off.
  148. =item B<-fallback_scsv>
  149. Send TLS_FALLBACK_SCSV in the ClientHello.
  150. =item B<-bugs>
  151. there are several known bug in SSL and TLS implementations. Adding this
  152. option enables various workarounds.
  153. =item B<-cipher cipherlist>
  154. this allows the cipher list sent by the client to be modified. Although
  155. the server determines which cipher suite is used it should take the first
  156. supported cipher in the list sent by the client. See the B<ciphers>
  157. command for more information.
  158. =item B<-starttls protocol>
  159. send the protocol-specific message(s) to switch to TLS for communication.
  160. B<protocol> is a keyword for the intended protocol. Currently, the only
  161. supported keywords are "smtp", "pop3", "imap", "ftp" and "xmpp".
  162. =item B<-xmpphost hostname>
  163. This option, when used with "-starttls xmpp", specifies the host for the
  164. "to" attribute of the stream element.
  165. If this option is not specified, then the host specified with "-connect"
  166. will be used.
  167. =item B<-tlsextdebug>
  168. print out a hex dump of any TLS extensions received from the server.
  169. =item B<-no_ticket>
  170. disable RFC4507bis session ticket support.
  171. =item B<-sess_out filename>
  172. output SSL session to B<filename>
  173. =item B<-sess_in sess.pem>
  174. load SSL session from B<filename>. The client will attempt to resume a
  175. connection from this session.
  176. =item B<-engine id>
  177. specifying an engine (by its unique B<id> string) will cause B<s_client>
  178. to attempt to obtain a functional reference to the specified engine,
  179. thus initialising it if needed. The engine will then be set as the default
  180. for all available algorithms.
  181. =item B<-rand file(s)>
  182. a file or files containing random data used to seed the random number
  183. generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
  184. Multiple files can be specified separated by a OS-dependent character.
  185. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  186. all others.
  187. =back
  188. =head1 CONNECTED COMMANDS
  189. If a connection is established with an SSL server then any data received
  190. from the server is displayed and any key presses will be sent to the
  191. server. When used interactively (which means neither B<-quiet> nor B<-ign_eof>
  192. have been given), the session will be renegotiated if the line begins with an
  193. B<R>, and if the line begins with a B<Q> or if end of file is reached, the
  194. connection will be closed down.
  195. =head1 NOTES
  196. B<s_client> can be used to debug SSL servers. To connect to an SSL HTTP
  197. server the command:
  198. openssl s_client -connect servername:443
  199. would typically be used (https uses port 443). If the connection succeeds
  200. then an HTTP command can be given such as "GET /" to retrieve a web page.
  201. If the handshake fails then there are several possible causes, if it is
  202. nothing obvious like no client certificate then the B<-bugs>, B<-ssl2>,
  203. B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> options can be tried
  204. in case it is a buggy server. In particular you should play with these
  205. options B<before> submitting a bug report to an OpenSSL mailing list.
  206. A frequent problem when attempting to get client certificates working
  207. is that a web client complains it has no certificates or gives an empty
  208. list to choose from. This is normally because the server is not sending
  209. the clients certificate authority in its "acceptable CA list" when it
  210. requests a certificate. By using B<s_client> the CA list can be viewed
  211. and checked. However some servers only request client authentication
  212. after a specific URL is requested. To obtain the list in this case it
  213. is necessary to use the B<-prexit> option and send an HTTP request
  214. for an appropriate page.
  215. If a certificate is specified on the command line using the B<-cert>
  216. option it will not be used unless the server specifically requests
  217. a client certificate. Therefor merely including a client certificate
  218. on the command line is no guarantee that the certificate works.
  219. If there are problems verifying a server certificate then the
  220. B<-showcerts> option can be used to show the whole chain.
  221. Since the SSLv23 client hello cannot include compression methods or extensions
  222. these will only be supported if its use is disabled, for example by using the
  223. B<-no_sslv2> option.
  224. The B<s_client> utility is a test tool and is designed to continue the
  225. handshake after any certificate verification errors. As a result it will
  226. accept any certificate chain (trusted or not) sent by the peer. None test
  227. applications should B<not> do this as it makes them vulnerable to a MITM
  228. attack.
  229. =head1 BUGS
  230. Because this program has a lot of options and also because some of
  231. the techniques used are rather old, the C source of s_client is rather
  232. hard to read and not a model of how things should be done. A typical
  233. SSL client program would be much simpler.
  234. The B<-prexit> option is a bit of a hack. We should really report
  235. information whenever a session is renegotiated.
  236. =head1 SEE ALSO
  237. L<sess_id(1)|sess_id(1)>, L<s_server(1)|s_server(1)>, L<ciphers(1)|ciphers(1)>
  238. =cut