s_client.pod 9.1 KB

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