s_client.pod 27 KB

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