s_client.pod 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. =pod
  2. =head1 NAME
  3. openssl-s_client,
  4. s_client - SSL/TLS client program
  5. =head1 SYNOPSIS
  6. B<openssl> B<s_client>
  7. [B<-help>]
  8. [B<-connect host:port>]
  9. [B<-bind host:port>]
  10. [B<-proxy host:port>]
  11. [B<-unix path>]
  12. [B<-4>]
  13. [B<-6>]
  14. [B<-servername name>]
  15. [B<-noservername>]
  16. [B<-verify depth>]
  17. [B<-verify_return_error>]
  18. [B<-cert filename>]
  19. [B<-certform DER|PEM>]
  20. [B<-key filename>]
  21. [B<-keyform DER|PEM>]
  22. [B<-cert_chain filename>]
  23. [B<-build_chain>]
  24. [B<-xkey>]
  25. [B<-xcert>]
  26. [B<-xchain>]
  27. [B<-xchain_build>]
  28. [B<-xcertform PEM|DER>]
  29. [B<-xkeyform PEM|DER>]
  30. [B<-pass arg>]
  31. [B<-CApath directory>]
  32. [B<-CAfile filename>]
  33. [B<-chainCApath directory>]
  34. [B<-chainCAfile filename>]
  35. [B<-no-CAfile>]
  36. [B<-no-CApath>]
  37. [B<-requestCAfile filename>]
  38. [B<-dane_tlsa_domain domain>]
  39. [B<-dane_tlsa_rrdata rrdata>]
  40. [B<-dane_ee_no_namechecks>]
  41. [B<-attime timestamp>]
  42. [B<-check_ss_sig>]
  43. [B<-crl_check>]
  44. [B<-crl_check_all>]
  45. [B<-explicit_policy>]
  46. [B<-extended_crl>]
  47. [B<-ignore_critical>]
  48. [B<-inhibit_any>]
  49. [B<-inhibit_map>]
  50. [B<-no_check_time>]
  51. [B<-partial_chain>]
  52. [B<-policy arg>]
  53. [B<-policy_check>]
  54. [B<-policy_print>]
  55. [B<-purpose purpose>]
  56. [B<-suiteB_128>]
  57. [B<-suiteB_128_only>]
  58. [B<-suiteB_192>]
  59. [B<-trusted_first>]
  60. [B<-no_alt_chains>]
  61. [B<-use_deltas>]
  62. [B<-auth_level num>]
  63. [B<-nameopt option>]
  64. [B<-verify_depth num>]
  65. [B<-verify_email email>]
  66. [B<-verify_hostname hostname>]
  67. [B<-verify_ip ip>]
  68. [B<-verify_name name>]
  69. [B<-build_chain>]
  70. [B<-x509_strict>]
  71. [B<-reconnect>]
  72. [B<-showcerts>]
  73. [B<-debug>]
  74. [B<-msg>]
  75. [B<-nbio_test>]
  76. [B<-state>]
  77. [B<-nbio>]
  78. [B<-crlf>]
  79. [B<-ign_eof>]
  80. [B<-no_ign_eof>]
  81. [B<-psk_identity identity>]
  82. [B<-psk key>]
  83. [B<-psk_session file>]
  84. [B<-quiet>]
  85. [B<-ssl3>]
  86. [B<-tls1>]
  87. [B<-tls1_1>]
  88. [B<-tls1_2>]
  89. [B<-tls1_3>]
  90. [B<-no_ssl3>]
  91. [B<-no_tls1>]
  92. [B<-no_tls1_1>]
  93. [B<-no_tls1_2>]
  94. [B<-no_tls1_3>]
  95. [B<-dtls>]
  96. [B<-dtls1>]
  97. [B<-dtls1_2>]
  98. [B<-sctp>]
  99. [B<-fallback_scsv>]
  100. [B<-async>]
  101. [B<-max_send_frag>]
  102. [B<-split_send_frag>]
  103. [B<-max_pipelines>]
  104. [B<-read_buf>]
  105. [B<-bugs>]
  106. [B<-comp>]
  107. [B<-no_comp>]
  108. [B<-allow_no_dhe_kex>]
  109. [B<-sigalgs sigalglist>]
  110. [B<-curves curvelist>]
  111. [B<-cipher cipherlist>]
  112. [B<-ciphersuites val>]
  113. [B<-serverpref>]
  114. [B<-starttls protocol>]
  115. [B<-xmpphost hostname>]
  116. [B<-name hostname>]
  117. [B<-engine id>]
  118. [B<-tlsextdebug>]
  119. [B<-no_ticket>]
  120. [B<-sess_out filename>]
  121. [B<-sess_in filename>]
  122. [B<-rand file...>]
  123. [B<-writerand file>]
  124. [B<-serverinfo types>]
  125. [B<-status>]
  126. [B<-alpn protocols>]
  127. [B<-nextprotoneg protocols>]
  128. [B<-ct>]
  129. [B<-noct>]
  130. [B<-ctlogfile>]
  131. [B<-keylogfile file>]
  132. [B<-early_data file>]
  133. [B<-enable_pha>]
  134. [B<target>]
  135. =head1 DESCRIPTION
  136. The B<s_client> command implements a generic SSL/TLS client which connects
  137. to a remote host using SSL/TLS. It is a I<very> useful diagnostic tool for
  138. SSL servers.
  139. =head1 OPTIONS
  140. In addition to the options below the B<s_client> utility also supports the
  141. common and client only options documented in the
  142. in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
  143. manual page.
  144. =over 4
  145. =item B<-help>
  146. Print out a usage message.
  147. =item B<-connect host:port>
  148. This specifies the host and optional port to connect to. It is possible to
  149. select the host and port using the optional target positional argument instead.
  150. If neither this nor the target positional argument are specified then an attempt
  151. is made to connect to the local host on port 4433.
  152. =item B<-bind host:port>]
  153. This specifies the host address and or port to bind as the source for the
  154. connection. For Unix-domain sockets the port is ignored and the host is
  155. used as the source socket address.
  156. =item B<-proxy host:port>
  157. When used with the B<-connect> flag, the program uses the host and port
  158. specified with this flag and issues an HTTP CONNECT command to connect
  159. to the desired server.
  160. =item B<-unix path>
  161. Connect over the specified Unix-domain socket.
  162. =item B<-4>
  163. Use IPv4 only.
  164. =item B<-6>
  165. Use IPv6 only.
  166. =item B<-servername name>
  167. Set the TLS SNI (Server Name Indication) extension in the ClientHello message to
  168. the given value. If both this option and the B<-noservername> are not given, the
  169. TLS SNI extension is still set to the hostname provided to the B<-connect> option,
  170. or "localhost" if B<-connect> has not been supplied. This is default since OpenSSL
  171. 1.1.1.
  172. Even though SNI name should normally be a DNS name and not an IP address, this
  173. option will not make the distinction when parsing B<-connect> and will send
  174. IP address if one passed.
  175. =item B<-noservername>
  176. Suppresses sending of the SNI (Server Name Indication) extension in the
  177. ClientHello message. Cannot be used in conjunction with the B<-servername> or
  178. <-dane_tlsa_domain> options.
  179. =item B<-cert certname>
  180. The certificate to use, if one is requested by the server. The default is
  181. not to use a certificate.
  182. =item B<-certform format>
  183. The certificate format to use: DER or PEM. PEM is the default.
  184. =item B<-key keyfile>
  185. The private key to use. If not specified then the certificate file will
  186. be used.
  187. =item B<-keyform format>
  188. The private format to use: DER or PEM. PEM is the default.
  189. =item B<-cert_chain>
  190. A file containing trusted certificates to use when attempting to build the
  191. client/server certificate chain related to the certificate specified via the
  192. B<-cert> option.
  193. =item B<-build_chain>
  194. Specify whether the application should build the certificate chain to be
  195. provided to the server.
  196. =item B<-xkey infile>, B<-xcert infile>, B<-xchain>
  197. Specify an extra certificate, private key and certificate chain. These behave
  198. in the same manner as the B<-cert>, B<-key> and B<-cert_chain> options. When
  199. specified, the callback returning the first valid chain will be in use by the
  200. client.
  201. =item B<-xchain_build>
  202. Specify whether the application should build the certificate chain to be
  203. provided to the server for the extra certificates provided via B<-xkey infile>,
  204. B<-xcert infile>, B<-xchain> options.
  205. =item B<-xcertform PEM|DER>, B<-xkeyform PEM|DER>
  206. Extra certificate and private key format respectively.
  207. =item B<-pass arg>
  208. the private key password source. For more information about the format of B<arg>
  209. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
  210. =item B<-verify depth>
  211. The verify depth to use. This specifies the maximum length of the
  212. server certificate chain and turns on server certificate verification.
  213. Currently the verify operation continues after errors so all the problems
  214. with a certificate chain can be seen. As a side effect the connection
  215. will never fail due to a server certificate verify failure.
  216. =item B<-verify_return_error>
  217. Return verification errors instead of continuing. This will typically
  218. abort the handshake with a fatal error.
  219. =item B<-nameopt option>
  220. Option which determines how the subject or issuer names are displayed. The
  221. B<option> argument can be a single option or multiple options separated by
  222. commas. Alternatively the B<-nameopt> switch may be used more than once to
  223. set multiple options. See the L<x509(1)> manual page for details.
  224. =item B<-CApath directory>
  225. The directory to use for server certificate verification. This directory
  226. must be in "hash format", see L<verify(1)> for more information. These are
  227. also used when building the client certificate chain.
  228. =item B<-CAfile file>
  229. A file containing trusted certificates to use during server authentication
  230. and to use when attempting to build the client certificate chain.
  231. =item B<-chainCApath directory>
  232. The directory to use for building the chain provided to the server. This
  233. directory must be in "hash format", see L<verify(1)> for more information.
  234. =item B<-chainCAfile file>
  235. A file containing trusted certificates to use when attempting to build the
  236. client certificate chain.
  237. =item B<-no-CAfile>
  238. Do not load the trusted CA certificates from the default file location
  239. =item B<-no-CApath>
  240. Do not load the trusted CA certificates from the default directory location
  241. =item B<-requestCAfile file>
  242. A file containing a list of certificates whose subject names will be sent
  243. to the server in the B<certificate_authorities> extension. Only supported
  244. for TLS 1.3
  245. =item B<-dane_tlsa_domain domain>
  246. Enable RFC6698/RFC7671 DANE TLSA authentication and specify the
  247. TLSA base domain which becomes the default SNI hint and the primary
  248. reference identifier for hostname checks. This must be used in
  249. combination with at least one instance of the B<-dane_tlsa_rrdata>
  250. option below.
  251. When DANE authentication succeeds, the diagnostic output will include
  252. the lowest (closest to 0) depth at which a TLSA record authenticated
  253. a chain certificate. When that TLSA record is a "2 1 0" trust
  254. anchor public key that signed (rather than matched) the top-most
  255. certificate of the chain, the result is reported as "TA public key
  256. verified". Otherwise, either the TLSA record "matched TA certificate"
  257. at a positive depth or else "matched EE certificate" at depth 0.
  258. =item B<-dane_tlsa_rrdata rrdata>
  259. Use one or more times to specify the RRDATA fields of the DANE TLSA
  260. RRset associated with the target service. The B<rrdata> value is
  261. specied in "presentation form", that is four whitespace separated
  262. fields that specify the usage, selector, matching type and associated
  263. data, with the last of these encoded in hexadecimal. Optional
  264. whitespace is ignored in the associated data field. For example:
  265. $ openssl s_client -brief -starttls smtp \
  266. -connect smtp.example.com:25 \
  267. -dane_tlsa_domain smtp.example.com \
  268. -dane_tlsa_rrdata "2 1 1
  269. B111DD8A1C2091A89BD4FD60C57F0716CCE50FEEFF8137CDBEE0326E 02CF362B" \
  270. -dane_tlsa_rrdata "2 1 1
  271. 60B87575447DCBA2A36B7D11AC09FB24A9DB406FEE12D2CC90180517 616E8A18"
  272. ...
  273. Verification: OK
  274. Verified peername: smtp.example.com
  275. DANE TLSA 2 1 1 ...ee12d2cc90180517616e8a18 matched TA certificate at depth 1
  276. ...
  277. =item B<-dane_ee_no_namechecks>
  278. This disables server name checks when authenticating via DANE-EE(3) TLSA
  279. records.
  280. For some applications, primarily web browsers, it is not safe to disable name
  281. checks due to "unknown key share" attacks, in which a malicious server can
  282. convince a client that a connection to a victim server is instead a secure
  283. connection to the malicious server.
  284. The malicious server may then be able to violate cross-origin scripting
  285. restrictions.
  286. Thus, despite the text of RFC7671, name checks are by default enabled for
  287. DANE-EE(3) TLSA records, and can be disabled in applications where it is safe
  288. to do so.
  289. In particular, SMTP and XMPP clients should set this option as SRV and MX
  290. records already make it possible for a remote domain to redirect client
  291. connections to any server of its choice, and in any case SMTP and XMPP clients
  292. do not execute scripts downloaded from remote servers.
  293. =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
  294. B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
  295. B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
  296. B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
  297. B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
  298. B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
  299. B<-verify_ip>, B<-verify_name>, B<-x509_strict>
  300. Set various certificate chain validation options. See the
  301. L<verify(1)> manual page for details.
  302. =item B<-reconnect>
  303. Reconnects to the same server 5 times using the same session ID, this can
  304. be used as a test that session caching is working.
  305. =item B<-showcerts>
  306. Displays the server certificate list as sent by the server: it only consists of
  307. certificates the server has sent (in the order the server has sent them). It is
  308. B<not> a verified chain.
  309. =item B<-prexit>
  310. Print session information when the program exits. This will always attempt
  311. to print out information even if the connection fails. Normally information
  312. will only be printed out once if the connection succeeds. This option is useful
  313. because the cipher in use may be renegotiated or the connection may fail
  314. because a client certificate is required or is requested only after an
  315. attempt is made to access a certain URL. Note: the output produced by this
  316. option is not always accurate because a connection might never have been
  317. established.
  318. =item B<-state>
  319. Prints out the SSL session states.
  320. =item B<-debug>
  321. Print extensive debugging information including a hex dump of all traffic.
  322. =item B<-msg>
  323. Show all protocol messages with hex dump.
  324. =item B<-trace>
  325. Show verbose trace output of protocol messages. OpenSSL needs to be compiled
  326. with B<enable-ssl-trace> for this option to work.
  327. =item B<-msgfile>
  328. File to send output of B<-msg> or B<-trace> to, default standard output.
  329. =item B<-nbio_test>
  330. Tests non-blocking I/O
  331. =item B<-nbio>
  332. Turns on non-blocking I/O
  333. =item B<-crlf>
  334. This option translated a line feed from the terminal into CR+LF as required
  335. by some servers.
  336. =item B<-ign_eof>
  337. Inhibit shutting down the connection when end of file is reached in the
  338. input.
  339. =item B<-quiet>
  340. Inhibit printing of session and certificate information. This implicitly
  341. turns on B<-ign_eof> as well.
  342. =item B<-no_ign_eof>
  343. Shut down the connection when end of file is reached in the input.
  344. Can be used to override the implicit B<-ign_eof> after B<-quiet>.
  345. =item B<-psk_identity identity>
  346. Use the PSK identity B<identity> when using a PSK cipher suite.
  347. The default value is "Client_identity" (without the quotes).
  348. =item B<-psk key>
  349. Use the PSK key B<key> when using a PSK cipher suite. The key is
  350. given as a hexadecimal number without leading 0x, for example -psk
  351. 1a2b3c4d.
  352. This option must be provided in order to use a PSK cipher.
  353. =item B<-psk_session file>
  354. Use the pem encoded SSL_SESSION data stored in B<file> as the basis of a PSK.
  355. Note that this will only work if TLSv1.3 is negotiated.
  356. =item B<-ssl3>, B<-tls1>, B<-tls1_1>, B<-tls1_2>, B<-tls1_3>, B<-no_ssl3>, B<-no_tls1>, B<-no_tls1_1>, B<-no_tls1_2>, B<-no_tls1_3>
  357. These options require or disable the use of the specified SSL or TLS protocols.
  358. By default B<s_client> will negotiate the highest mutually supported protocol
  359. version.
  360. When a specific TLS version is required, only that version will be offered to
  361. and accepted from the server.
  362. Note that not all protocols and flags may be available, depending on how
  363. OpenSSL was built.
  364. =item B<-dtls>, B<-dtls1>, B<-dtls1_2>
  365. These options make B<s_client> use DTLS protocols instead of TLS.
  366. With B<-dtls>, B<s_client> will negotiate any supported DTLS protocol version,
  367. whilst B<-dtls1> and B<-dtls1_2> will only support DTLS1.0 and DTLS1.2
  368. respectively.
  369. =item B<-sctp>
  370. Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
  371. conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
  372. available where OpenSSL has support for SCTP enabled.
  373. =item B<-fallback_scsv>
  374. Send TLS_FALLBACK_SCSV in the ClientHello.
  375. =item B<-async>
  376. Switch on asynchronous mode. Cryptographic operations will be performed
  377. asynchronously. This will only have an effect if an asynchronous capable engine
  378. is also used via the B<-engine> option. For test purposes the dummy async engine
  379. (dasync) can be used (if available).
  380. =item B<-max_send_frag int>
  381. The maximum size of data fragment to send.
  382. See L<SSL_CTX_set_max_send_fragment(3)> for further information.
  383. =item B<-split_send_frag int>
  384. The size used to split data for encrypt pipelines. If more data is written in
  385. one go than this value then it will be split into multiple pipelines, up to the
  386. maximum number of pipelines defined by max_pipelines. This only has an effect if
  387. a suitable cipher suite has been negotiated, an engine that supports pipelining
  388. has been loaded, and max_pipelines is greater than 1. See
  389. L<SSL_CTX_set_split_send_fragment(3)> for further information.
  390. =item B<-max_pipelines int>
  391. The maximum number of encrypt/decrypt pipelines to be used. This will only have
  392. an effect if an engine has been loaded that supports pipelining (e.g. the dasync
  393. engine) and a suitable cipher suite has been negotiated. The default value is 1.
  394. See L<SSL_CTX_set_max_pipelines(3)> for further information.
  395. =item B<-read_buf int>
  396. The default read buffer size to be used for connections. This will only have an
  397. effect if the buffer size is larger than the size that would otherwise be used
  398. and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
  399. further information).
  400. =item B<-bugs>
  401. There are several known bug in SSL and TLS implementations. Adding this
  402. option enables various workarounds.
  403. =item B<-comp>
  404. Enables support for SSL/TLS compression.
  405. This option was introduced in OpenSSL 1.1.0.
  406. TLS compression is not recommended and is off by default as of
  407. OpenSSL 1.1.0.
  408. =item B<-no_comp>
  409. Disables support for SSL/TLS compression.
  410. TLS compression is not recommended and is off by default as of
  411. OpenSSL 1.1.0.
  412. =item B<-brief>
  413. Only provide a brief summary of connection parameters instead of the
  414. normal verbose output.
  415. =item B<-sigalgs sigalglist>
  416. Specifies the list of signature algorithms that are sent by the client.
  417. The server selects one entry in the list based on its preferences.
  418. For example strings, see L<SSL_CTX_set1_sigalgs(3)>
  419. =item B<-curves curvelist>
  420. Specifies the list of supported curves to be sent by the client. The curve is
  421. ultimately selected by the server. For a list of all curves, use:
  422. $ openssl ecparam -list_curves
  423. =item B<-cipher cipherlist>
  424. This allows the TLSv1.2 and below cipher list sent by the client to be modified.
  425. This list will be combined with any TLSv1.3 ciphersuites that have been
  426. configured. Although the server determines which ciphersuite is used it should
  427. take the first supported cipher in the list sent by the client. See the
  428. B<ciphers> command for more information.
  429. =item B<-ciphersuites val>
  430. This allows the TLSv1.3 ciphersuites sent by the client to be modified. This
  431. list will be combined with any TLSv1.2 and below ciphersuites that have been
  432. configured. Although the server determines which cipher suite is used it should
  433. take the first supported cipher in the list sent by the client. See the
  434. B<ciphers> command for more information. The format for this list is a simple
  435. colon (":") separated list of TLSv1.3 ciphersuite names.
  436. =item B<-starttls protocol>
  437. Send the protocol-specific message(s) to switch to TLS for communication.
  438. B<protocol> is a keyword for the intended protocol. Currently, the only
  439. supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server",
  440. "irc", "postgres", "mysql", "lmtp", "nntp", "sieve" and "ldap".
  441. =item B<-xmpphost hostname>
  442. This option, when used with "-starttls xmpp" or "-starttls xmpp-server",
  443. specifies the host for the "to" attribute of the stream element.
  444. If this option is not specified, then the host specified with "-connect"
  445. will be used.
  446. This option is an alias of the B<-name> option for "xmpp" and "xmpp-server".
  447. =item B<-name hostname>
  448. This option is used to specify hostname information for various protocols
  449. used with B<-starttls> option. Currently only "xmpp", "xmpp-server",
  450. "smtp" and "lmtp" can utilize this B<-name> option.
  451. If this option is used with "-starttls xmpp" or "-starttls xmpp-server",
  452. if specifies the host for the "to" attribute of the stream element. If this
  453. option is not specified, then the host specified with "-connect" will be used.
  454. If this option is used with "-starttls lmtp" or "-starttls smtp", it specifies
  455. the name to use in the "LMTP LHLO" or "SMTP EHLO" message, respectively. If
  456. this option is not specified, then "mail.example.com" will be used.
  457. =item B<-tlsextdebug>
  458. Print out a hex dump of any TLS extensions received from the server.
  459. =item B<-no_ticket>
  460. Disable RFC4507bis session ticket support.
  461. =item B<-sess_out filename>
  462. Output SSL session to B<filename>.
  463. =item B<-sess_in sess.pem>
  464. Load SSL session from B<filename>. The client will attempt to resume a
  465. connection from this session.
  466. =item B<-engine id>
  467. Specifying an engine (by its unique B<id> string) will cause B<s_client>
  468. to attempt to obtain a functional reference to the specified engine,
  469. thus initialising it if needed. The engine will then be set as the default
  470. for all available algorithms.
  471. =item B<-rand file...>
  472. A file or files containing random data used to seed the random number
  473. generator.
  474. Multiple files can be specified separated by an OS-dependent character.
  475. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  476. all others.
  477. =item [B<-writerand file>]
  478. Writes random data to the specified I<file> upon exit.
  479. This can be used with a subsequent B<-rand> flag.
  480. =item B<-serverinfo types>
  481. A list of comma-separated TLS Extension Types (numbers between 0 and
  482. 65535). Each type will be sent as an empty ClientHello TLS Extension.
  483. The server's response (if any) will be encoded and displayed as a PEM
  484. file.
  485. =item B<-status>
  486. Sends a certificate status request to the server (OCSP stapling). The server
  487. response (if any) is printed out.
  488. =item B<-alpn protocols>, B<-nextprotoneg protocols>
  489. These flags enable the Enable the Application-Layer Protocol Negotiation
  490. or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
  491. IETF standard and replaces NPN.
  492. The B<protocols> list is a comma-separated list of protocol names that
  493. the client should advertise support for. The list should contain the most
  494. desirable protocols first. Protocol names are printable ASCII strings,
  495. for example "http/1.1" or "spdy/3".
  496. An empty list of protocols is treated specially and will cause the
  497. client to advertise support for the TLS extension but disconnect just
  498. after receiving ServerHello with a list of server supported protocols.
  499. The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
  500. =item B<-ct>, B<-noct>
  501. Use one of these two options to control whether Certificate Transparency (CT)
  502. is enabled (B<-ct>) or disabled (B<-noct>).
  503. If CT is enabled, signed certificate timestamps (SCTs) will be requested from
  504. the server and reported at handshake completion.
  505. Enabling CT also enables OCSP stapling, as this is one possible delivery method
  506. for SCTs.
  507. =item B<-ctlogfile>
  508. A file containing a list of known Certificate Transparency logs. See
  509. L<SSL_CTX_set_ctlog_list_file(3)> for the expected file format.
  510. =item B<-keylogfile file>
  511. Appends TLS secrets to the specified keylog file such that external programs
  512. (like Wireshark) can decrypt TLS connections.
  513. =item B<-early_data file>
  514. Reads the contents of the specified file and attempts to send it as early data
  515. to the server. This will only work with resumed sessions that support early
  516. data and when the server accepts the early data.
  517. =item B<-enable_pha>
  518. For TLSv1.3 only, send the Post-Handshake Authentication extension. This will
  519. happen whether or not a certificate has been provided via B<-cert>.
  520. =item B<[target]>
  521. Rather than providing B<-connect>, the target hostname and optional port may
  522. be provided as a single positional argument after all options. If neither this
  523. nor B<-connect> are provided, falls back to attempting to connect to localhost
  524. on port 4433.
  525. =back
  526. =head1 CONNECTED COMMANDS
  527. If a connection is established with an SSL server then any data received
  528. from the server is displayed and any key presses will be sent to the
  529. server. If end of file is reached then the connection will be closed down. When
  530. used interactively (which means neither B<-quiet> nor B<-ign_eof> have been
  531. given), then certain commands are also recognized which perform special
  532. operations. These commands are a letter which must appear at the start of a
  533. line. They are listed below.
  534. =over 4
  535. =item B<Q>
  536. End the current SSL connection and exit.
  537. =item B<R>
  538. Renegotiate the SSL session (TLSv1.2 and below only).
  539. =item B<B>
  540. Send a heartbeat message to the server (DTLS only)
  541. =item B<k>
  542. Send a key update message to the server (TLSv1.3 only)
  543. =item B<K>
  544. Send a key update message to the server and request one back (TLSv1.3 only)
  545. =back
  546. =head1 NOTES
  547. B<s_client> can be used to debug SSL servers. To connect to an SSL HTTP
  548. server the command:
  549. openssl s_client -connect servername:443
  550. would typically be used (https uses port 443). If the connection succeeds
  551. then an HTTP command can be given such as "GET /" to retrieve a web page.
  552. If the handshake fails then there are several possible causes, if it is
  553. nothing obvious like no client certificate then the B<-bugs>,
  554. B<-ssl3>, B<-tls1>, B<-no_ssl3>, B<-no_tls1> options can be tried
  555. in case it is a buggy server. In particular you should play with these
  556. options B<before> submitting a bug report to an OpenSSL mailing list.
  557. A frequent problem when attempting to get client certificates working
  558. is that a web client complains it has no certificates or gives an empty
  559. list to choose from. This is normally because the server is not sending
  560. the clients certificate authority in its "acceptable CA list" when it
  561. requests a certificate. By using B<s_client> the CA list can be viewed
  562. and checked. However some servers only request client authentication
  563. after a specific URL is requested. To obtain the list in this case it
  564. is necessary to use the B<-prexit> option and send an HTTP request
  565. for an appropriate page.
  566. If a certificate is specified on the command line using the B<-cert>
  567. option it will not be used unless the server specifically requests
  568. a client certificate. Therefor merely including a client certificate
  569. on the command line is no guarantee that the certificate works.
  570. If there are problems verifying a server certificate then the
  571. B<-showcerts> option can be used to show all the certificates sent by the
  572. server.
  573. The B<s_client> utility is a test tool and is designed to continue the
  574. handshake after any certificate verification errors. As a result it will
  575. accept any certificate chain (trusted or not) sent by the peer. None test
  576. applications should B<not> do this as it makes them vulnerable to a MITM
  577. attack. This behaviour can be changed by with the B<-verify_return_error>
  578. option: any verify errors are then returned aborting the handshake.
  579. The B<-bind> option may be useful if the server or a firewall requires
  580. connections to come from some particular address and or port.
  581. =head1 BUGS
  582. Because this program has a lot of options and also because some of the
  583. techniques used are rather old, the C source of B<s_client> is rather hard to
  584. read and not a model of how things should be done.
  585. A typical SSL client program would be much simpler.
  586. The B<-prexit> option is a bit of a hack. We should really report
  587. information whenever a session is renegotiated.
  588. =head1 SEE ALSO
  589. L<SSL_CONF_cmd(3)>, L<sess_id(1)>, L<s_server(1)>, L<ciphers(1)>,
  590. L<SSL_CTX_set_max_send_fragment(3)>, L<SSL_CTX_set_split_send_fragment(3)>,
  591. L<SSL_CTX_set_max_pipelines(3)>
  592. =head1 HISTORY
  593. The B<-no_alt_chains> option was added in OpenSSL 1.1.0.
  594. The B<-name> option was added in OpenSSL 1.1.1.
  595. =head1 COPYRIGHT
  596. Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
  597. Licensed under the Apache License 2.0 (the "License"). You may not use
  598. this file except in compliance with the License. You can obtain a copy
  599. in the file LICENSE in the source distribution or at
  600. L<https://www.openssl.org/source/license.html>.
  601. =cut