openssl-s_client.pod.in 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-s_client - SSL/TLS client program
  5. =head1 SYNOPSIS
  6. B<openssl> B<s_client>
  7. [B<-help>]
  8. [B<-ssl_config> I<section>]
  9. [B<-connect> I<host>:I<port>]
  10. [B<-host> I<hostname>]
  11. [B<-port> I<port>]
  12. [B<-bind> I<host>:I<port>]
  13. [B<-proxy> I<host>:I<port>]
  14. [B<-proxy_user> I<userid>]
  15. [B<-proxy_pass> I<arg>]
  16. [B<-unix> I<path>]
  17. [B<-4>]
  18. [B<-6>]
  19. [B<-quic>]
  20. [B<-servername> I<name>]
  21. [B<-noservername>]
  22. [B<-verify> I<depth>]
  23. [B<-verify_return_error>]
  24. [B<-verify_quiet>]
  25. [B<-verifyCAfile> I<filename>]
  26. [B<-verifyCApath> I<dir>]
  27. [B<-verifyCAstore> I<uri>]
  28. [B<-cert> I<filename>]
  29. [B<-certform> B<DER>|B<PEM>|B<P12>]
  30. [B<-cert_chain> I<filename>]
  31. [B<-build_chain>]
  32. [B<-CRL> I<filename>]
  33. [B<-CRLform> B<DER>|B<PEM>]
  34. [B<-crl_download>]
  35. [B<-key> I<filename>|I<uri>]
  36. [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
  37. [B<-pass> I<arg>]
  38. [B<-chainCAfile> I<filename>]
  39. [B<-chainCApath> I<directory>]
  40. [B<-chainCAstore> I<uri>]
  41. [B<-requestCAfile> I<filename>]
  42. [B<-dane_tlsa_domain> I<domain>]
  43. [B<-dane_tlsa_rrdata> I<rrdata>]
  44. [B<-dane_ee_no_namechecks>]
  45. [B<-reconnect>]
  46. [B<-showcerts>]
  47. [B<-prexit>]
  48. [B<-no-interactive>]
  49. [B<-debug>]
  50. [B<-trace>]
  51. [B<-nocommands>]
  52. [B<-adv>]
  53. [B<-security_debug>]
  54. [B<-security_debug_verbose>]
  55. [B<-msg>]
  56. [B<-timeout>]
  57. [B<-mtu> I<size>]
  58. [B<-no_etm>]
  59. [B<-no_ems>]
  60. [B<-keymatexport> I<label>]
  61. [B<-keymatexportlen> I<len>]
  62. [B<-msgfile> I<filename>]
  63. [B<-nbio_test>]
  64. [B<-state>]
  65. [B<-nbio>]
  66. [B<-crlf>]
  67. [B<-ign_eof>]
  68. [B<-no_ign_eof>]
  69. [B<-psk_identity> I<identity>]
  70. [B<-psk> I<key>]
  71. [B<-psk_session> I<file>]
  72. [B<-quiet>]
  73. [B<-sctp>]
  74. [B<-sctp_label_bug>]
  75. [B<-fallback_scsv>]
  76. [B<-async>]
  77. [B<-maxfraglen> I<len>]
  78. [B<-max_send_frag>]
  79. [B<-split_send_frag>]
  80. [B<-max_pipelines>]
  81. [B<-read_buf>]
  82. [B<-ignore_unexpected_eof>]
  83. [B<-bugs>]
  84. [B<-no_tx_cert_comp>]
  85. [B<-no_rx_cert_comp>]
  86. [B<-comp>]
  87. [B<-no_comp>]
  88. [B<-brief>]
  89. [B<-legacy_server_connect>]
  90. [B<-no_legacy_server_connect>]
  91. [B<-allow_no_dhe_kex>]
  92. [B<-prefer_no_dhe_kex>]
  93. [B<-sigalgs> I<sigalglist>]
  94. [B<-curves> I<curvelist>]
  95. [B<-cipher> I<cipherlist>]
  96. [B<-ciphersuites> I<val>]
  97. [B<-serverpref>]
  98. [B<-starttls> I<protocol>]
  99. [B<-name> I<hostname>]
  100. [B<-xmpphost> I<hostname>]
  101. [B<-name> I<hostname>]
  102. [B<-tlsextdebug>]
  103. [B<-no_ticket>]
  104. [B<-sess_out> I<filename>]
  105. [B<-serverinfo> I<types>]
  106. [B<-sess_in> I<filename>]
  107. [B<-serverinfo> I<types>]
  108. [B<-status>]
  109. [B<-alpn> I<protocols>]
  110. [B<-nextprotoneg> I<protocols>]
  111. [B<-ct>]
  112. [B<-noct>]
  113. [B<-ctlogfile>]
  114. [B<-keylogfile> I<file>]
  115. [B<-early_data> I<file>]
  116. [B<-enable_pha>]
  117. [B<-use_srtp> I<value>]
  118. [B<-srpuser> I<value>]
  119. [B<-srppass> I<value>]
  120. [B<-srp_lateuser>]
  121. [B<-srp_moregroups>]
  122. [B<-srp_strength> I<number>]
  123. [B<-ktls>]
  124. [B<-tfo>]
  125. {- $OpenSSL::safe::opt_name_synopsis -}
  126. {- $OpenSSL::safe::opt_version_synopsis -}
  127. {- $OpenSSL::safe::opt_x_synopsis -}
  128. {- $OpenSSL::safe::opt_trust_synopsis -}
  129. {- $OpenSSL::safe::opt_s_synopsis -}
  130. {- $OpenSSL::safe::opt_r_synopsis -}
  131. {- $OpenSSL::safe::opt_provider_synopsis -}
  132. {- $OpenSSL::safe::opt_engine_synopsis -}[B<-ssl_client_engine> I<id>]
  133. {- $OpenSSL::safe::opt_v_synopsis -}
  134. [B<-enable_server_rpk>]
  135. [B<-enable_client_rpk>]
  136. [I<host>:I<port>]
  137. =head1 DESCRIPTION
  138. This command implements a generic SSL/TLS client which
  139. connects to a remote host using SSL/TLS. It is a I<very> useful diagnostic
  140. tool for SSL servers.
  141. =head1 OPTIONS
  142. In addition to the options below, this command also supports the
  143. common and client only options documented
  144. in the "Supported Command Line Commands" section of the L<SSL_CONF_cmd(3)>
  145. manual page.
  146. =over 4
  147. =item B<-help>
  148. Print out a usage message.
  149. =item B<-ssl_config> I<section>
  150. Use the specified section of the configuration file to configure the B<SSL_CTX> object.
  151. =item B<-connect> I<host>:I<port>
  152. This specifies the host and optional port to connect to. It is possible to
  153. select the host and port using the optional target positional argument instead.
  154. If neither this nor the target positional argument are specified then an attempt
  155. is made to connect to the local host on port 4433.
  156. If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>.
  157. =item B<-host> I<hostname>
  158. Host to connect to; use B<-connect> instead.
  159. =item B<-port> I<port>
  160. Connect to the specified port; use B<-connect> instead.
  161. =item B<-bind> I<host>:I<port>
  162. This specifies the host address and or port to bind as the source for the
  163. connection. For Unix-domain sockets the port is ignored and the host is
  164. used as the source socket address.
  165. If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>.
  166. =item B<-proxy> I<host>:I<port>
  167. When used with the B<-connect> flag, the program uses the host and port
  168. specified with this flag and issues an HTTP CONNECT command to connect
  169. to the desired server.
  170. If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>.
  171. =item B<-proxy_user> I<userid>
  172. When used with the B<-proxy> flag, the program will attempt to authenticate
  173. with the specified proxy using basic (base64) authentication.
  174. NB: Basic authentication is insecure; the credentials are sent to the proxy
  175. in easily reversible base64 encoding before any TLS/SSL session is established.
  176. Therefore, these credentials are easily recovered by anyone able to sniff/trace
  177. the network. Use with caution.
  178. =item B<-proxy_pass> I<arg>
  179. The proxy password source, used with the B<-proxy_user> flag.
  180. For more information about the format of B<arg>
  181. see L<openssl-passphrase-options(1)>.
  182. =item B<-unix> I<path>
  183. Connect over the specified Unix-domain socket.
  184. =item B<-4>
  185. Use IPv4 only.
  186. =item B<-6>
  187. Use IPv6 only.
  188. =item B<-quic>
  189. Connect using the QUIC protocol. If specified then the B<-alpn> option must also
  190. be provided.
  191. =item B<-servername> I<name>
  192. Set the TLS SNI (Server Name Indication) extension in the ClientHello message to
  193. the given value.
  194. If B<-servername> is not provided, the TLS SNI extension will be populated with
  195. the name given to B<-connect> if it follows a DNS name format. If B<-connect> is
  196. not provided either, the SNI is set to "localhost".
  197. This is the default since OpenSSL 1.1.1.
  198. Even though SNI should normally be a DNS name and not an IP address, if
  199. B<-servername> is provided then that name will be sent, regardless of whether
  200. it is a DNS name or not.
  201. This option cannot be used in conjunction with B<-noservername>.
  202. =item B<-noservername>
  203. Suppresses sending of the SNI (Server Name Indication) extension in the
  204. ClientHello message. Cannot be used in conjunction with the B<-servername> or
  205. B<-dane_tlsa_domain> options.
  206. =item B<-cert> I<filename>
  207. The client certificate to use, if one is requested by the server.
  208. The default is not to use a certificate.
  209. The chain for the client certificate may be specified using B<-cert_chain>.
  210. =item B<-certform> B<DER>|B<PEM>|B<P12>
  211. The client certificate file format to use; unspecified by default.
  212. See L<openssl-format-options(1)> for details.
  213. =item B<-cert_chain>
  214. A file or URI of untrusted certificates to use when attempting to build the
  215. certificate chain related to the certificate specified via the B<-cert> option.
  216. The input can be in PEM, DER, or PKCS#12 format.
  217. =item B<-build_chain>
  218. Specify whether the application should build the client certificate chain to be
  219. provided to the server.
  220. =item B<-CRL> I<filename>
  221. CRL file to use to check the server's certificate.
  222. =item B<-CRLform> B<DER>|B<PEM>
  223. The CRL file format; unspecified by default.
  224. See L<openssl-format-options(1)> for details.
  225. =item B<-crl_download>
  226. Download CRL from distribution points in the certificate. Note that this option
  227. is ignored if B<-crl_check> option is not provided. Note that the maximum size
  228. of CRL is limited by L<X509_CRL_load_http(3)> function.
  229. =item B<-key> I<filename>|I<uri>
  230. The client private key to use.
  231. If not specified then the certificate file will be used to read also the key.
  232. =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
  233. The key format; unspecified by default.
  234. See L<openssl-format-options(1)> for details.
  235. =item B<-pass> I<arg>
  236. the private key and certificate file password source.
  237. For more information about the format of I<arg>
  238. see L<openssl-passphrase-options(1)>.
  239. =item B<-verify> I<depth>
  240. The verify depth to use. This specifies the maximum length of the
  241. server certificate chain and turns on server certificate verification.
  242. Unless the B<-verify_return_error> option is given,
  243. the verify operation continues after errors so all the problems
  244. with a certificate chain can be seen. As a side effect the connection
  245. will never fail due to a server certificate verify failure.
  246. By default, validation of server certificates and their chain
  247. is done w.r.t. the (D)TLS Server (C<sslserver>) purpose.
  248. For details see L<openssl-verification-options(1)/Certificate Extensions>.
  249. =item B<-verify_return_error>
  250. Turns on server certificate verification, like with B<-verify>,
  251. but returns verification errors instead of continuing.
  252. This will typically abort the handshake with a fatal error.
  253. =item B<-verify_quiet>
  254. Limit verify output to only errors.
  255. =item B<-verifyCAfile> I<filename>
  256. A file in PEM format containing trusted certificates to use
  257. for verifying the server's certificate.
  258. =item B<-verifyCApath> I<dir>
  259. A directory containing trusted certificates to use
  260. for verifying the server's certificate.
  261. This directory must be in "hash format",
  262. see L<openssl-verify(1)> for more information.
  263. =item B<-verifyCAstore> I<uri>
  264. The URI of a store containing trusted certificates to use
  265. for verifying the server's certificate.
  266. =item B<-chainCAfile> I<file>
  267. A file in PEM format containing trusted certificates to use
  268. when attempting to build the client certificate chain.
  269. =item B<-chainCApath> I<directory>
  270. A directory containing trusted certificates to use
  271. for building the client certificate chain provided to the server.
  272. This directory must be in "hash format",
  273. see L<openssl-verify(1)> for more information.
  274. =item B<-chainCAstore> I<uri>
  275. The URI of a store containing trusted certificates to use
  276. when attempting to build the client certificate chain.
  277. The URI may indicate a single certificate, as well as a collection of them.
  278. With URIs in the C<file:> scheme, this acts as B<-chainCAfile> or
  279. B<-chainCApath>, depending on if the URI indicates a directory or a
  280. single file.
  281. See L<ossl_store-file(7)> for more information on the C<file:> scheme.
  282. =item B<-requestCAfile> I<file>
  283. A file containing a list of certificates whose subject names will be sent
  284. to the server in the B<certificate_authorities> extension. Only supported
  285. for TLS 1.3
  286. =item B<-dane_tlsa_domain> I<domain>
  287. Enable RFC6698/RFC7671 DANE TLSA authentication and specify the
  288. TLSA base domain which becomes the default SNI hint and the primary
  289. reference identifier for hostname checks. This must be used in
  290. combination with at least one instance of the B<-dane_tlsa_rrdata>
  291. option below.
  292. When DANE authentication succeeds, the diagnostic output will include
  293. the lowest (closest to 0) depth at which a TLSA record authenticated
  294. a chain certificate. When that TLSA record is a "2 1 0" trust
  295. anchor public key that signed (rather than matched) the top-most
  296. certificate of the chain, the result is reported as "TA public key
  297. verified". Otherwise, either the TLSA record "matched TA certificate"
  298. at a positive depth or else "matched EE certificate" at depth 0.
  299. =item B<-dane_tlsa_rrdata> I<rrdata>
  300. Use one or more times to specify the RRDATA fields of the DANE TLSA
  301. RRset associated with the target service. The I<rrdata> value is
  302. specified in "presentation form", that is four whitespace separated
  303. fields that specify the usage, selector, matching type and associated
  304. data, with the last of these encoded in hexadecimal. Optional
  305. whitespace is ignored in the associated data field. For example:
  306. $ openssl s_client -brief -starttls smtp \
  307. -connect smtp.example.com:25 \
  308. -dane_tlsa_domain smtp.example.com \
  309. -dane_tlsa_rrdata "2 1 1
  310. B111DD8A1C2091A89BD4FD60C57F0716CCE50FEEFF8137CDBEE0326E 02CF362B" \
  311. -dane_tlsa_rrdata "2 1 1
  312. 60B87575447DCBA2A36B7D11AC09FB24A9DB406FEE12D2CC90180517 616E8A18"
  313. ...
  314. Verification: OK
  315. Verified peername: smtp.example.com
  316. DANE TLSA 2 1 1 ...ee12d2cc90180517616e8a18 matched TA certificate at depth 1
  317. ...
  318. =item B<-dane_ee_no_namechecks>
  319. This disables server name checks when authenticating via DANE-EE(3) TLSA
  320. records.
  321. For some applications, primarily web browsers, it is not safe to disable name
  322. checks due to "unknown key share" attacks, in which a malicious server can
  323. convince a client that a connection to a victim server is instead a secure
  324. connection to the malicious server.
  325. The malicious server may then be able to violate cross-origin scripting
  326. restrictions.
  327. Thus, despite the text of RFC7671, name checks are by default enabled for
  328. DANE-EE(3) TLSA records, and can be disabled in applications where it is safe
  329. to do so.
  330. In particular, SMTP and XMPP clients should set this option as SRV and MX
  331. records already make it possible for a remote domain to redirect client
  332. connections to any server of its choice, and in any case SMTP and XMPP clients
  333. do not execute scripts downloaded from remote servers.
  334. =item B<-reconnect>
  335. Reconnects to the same server 5 times using the same session ID, this can
  336. be used as a test that session caching is working.
  337. =item B<-showcerts>
  338. Displays the server certificate list as sent by the server: it only consists of
  339. certificates the server has sent (in the order the server has sent them). It is
  340. B<not> a verified chain.
  341. =item B<-prexit>
  342. Print session information when the program exits. This will always attempt
  343. to print out information even if the connection fails. Normally information
  344. will only be printed out once if the connection succeeds. This option is useful
  345. because the cipher in use may be renegotiated or the connection may fail
  346. because a client certificate is required or is requested only after an
  347. attempt is made to access a certain URL. Note: the output produced by this
  348. option is not always accurate because a connection might never have been
  349. established.
  350. =item B<-no-interactive>
  351. This flag can be used to run the client in a non-interactive mode.
  352. =item B<-state>
  353. Prints out the SSL session states.
  354. =item B<-debug>
  355. Print extensive debugging information including a hex dump of all traffic.
  356. =item B<-nocommands>
  357. Do not use interactive command letters.
  358. =item B<-adv>
  359. Use advanced command mode.
  360. =item B<-security_debug>
  361. Enable security debug messages.
  362. =item B<-security_debug_verbose>
  363. Output more security debug output.
  364. =item B<-msg>
  365. Show protocol messages.
  366. =item B<-timeout>
  367. Enable send/receive timeout on DTLS connections.
  368. =item B<-mtu> I<size>
  369. Set MTU of the link layer to the specified size.
  370. =item B<-no_etm>
  371. Disable Encrypt-then-MAC negotiation.
  372. =item B<-no_ems>
  373. Disable Extended master secret negotiation.
  374. =item B<-keymatexport> I<label>
  375. Export keying material using the specified label.
  376. =item B<-keymatexportlen> I<len>
  377. Export the specified number of bytes of keying material; default is 20.
  378. Show all protocol messages with hex dump.
  379. =item B<-trace>
  380. Show verbose trace output of protocol messages.
  381. =item B<-msgfile> I<filename>
  382. File to send output of B<-msg> or B<-trace> to, default standard output.
  383. =item B<-nbio_test>
  384. Tests nonblocking I/O
  385. =item B<-nbio>
  386. Turns on nonblocking I/O
  387. =item B<-crlf>
  388. This option translated a line feed from the terminal into CR+LF as required
  389. by some servers.
  390. =item B<-ign_eof>
  391. Inhibit shutting down the connection when end of file is reached in the
  392. input. This implicitly turns on B<-nocommands> as well.
  393. =item B<-quiet>
  394. Inhibit printing of session and certificate information. This implicitly
  395. turns on B<-ign_eof> and B<-nocommands> as well.
  396. =item B<-no_ign_eof>
  397. Shut down the connection when end of file is reached in the input.
  398. Can be used to override the implicit B<-ign_eof> after B<-quiet>.
  399. =item B<-psk_identity> I<identity>
  400. Use the PSK identity I<identity> when using a PSK cipher suite.
  401. The default value is "Client_identity" (without the quotes).
  402. =item B<-psk> I<key>
  403. Use the PSK key I<key> when using a PSK cipher suite. The key is
  404. given as a hexadecimal number without leading 0x, for example -psk
  405. 1a2b3c4d.
  406. This option must be provided in order to use a PSK cipher.
  407. =item B<-psk_session> I<file>
  408. Use the pem encoded SSL_SESSION data stored in I<file> as the basis of a PSK.
  409. Note that this will only work if TLSv1.3 is negotiated.
  410. =item B<-sctp>
  411. Use SCTP for the transport protocol instead of UDP in DTLS. Must be used in
  412. conjunction with B<-dtls>, B<-dtls1> or B<-dtls1_2>. This option is only
  413. available where OpenSSL has support for SCTP enabled.
  414. =item B<-sctp_label_bug>
  415. Use the incorrect behaviour of older OpenSSL implementations when computing
  416. endpoint-pair shared secrets for DTLS/SCTP. This allows communication with
  417. older broken implementations but breaks interoperability with correct
  418. implementations. Must be used in conjunction with B<-sctp>. This option is only
  419. available where OpenSSL has support for SCTP enabled.
  420. =item B<-fallback_scsv>
  421. Send TLS_FALLBACK_SCSV in the ClientHello.
  422. =item B<-async>
  423. Switch on asynchronous mode. Cryptographic operations will be performed
  424. asynchronously. This will only have an effect if an asynchronous capable engine
  425. is also used via the B<-engine> option. For test purposes the dummy async engine
  426. (dasync) can be used (if available).
  427. =item B<-maxfraglen> I<len>
  428. Enable Maximum Fragment Length Negotiation; allowed values are
  429. C<512>, C<1024>, C<2048>, and C<4096>.
  430. =item B<-max_send_frag> I<int>
  431. The maximum size of data fragment to send.
  432. See L<SSL_CTX_set_max_send_fragment(3)> for further information.
  433. =item B<-split_send_frag> I<int>
  434. The size used to split data for encrypt pipelines. If more data is written in
  435. one go than this value then it will be split into multiple pipelines, up to the
  436. maximum number of pipelines defined by max_pipelines. This only has an effect if
  437. a suitable cipher suite has been negotiated, an engine that supports pipelining
  438. has been loaded, and max_pipelines is greater than 1. See
  439. L<SSL_CTX_set_split_send_fragment(3)> for further information.
  440. =item B<-max_pipelines> I<int>
  441. The maximum number of encrypt/decrypt pipelines to be used. This will only have
  442. an effect if an engine has been loaded that supports pipelining (e.g. the dasync
  443. engine) and a suitable cipher suite has been negotiated. The default value is 1.
  444. See L<SSL_CTX_set_max_pipelines(3)> for further information.
  445. =item B<-read_buf> I<int>
  446. The default read buffer size to be used for connections. This will only have an
  447. effect if the buffer size is larger than the size that would otherwise be used
  448. and pipelining is in use (see L<SSL_CTX_set_default_read_buffer_len(3)> for
  449. further information).
  450. =item B<-ignore_unexpected_eof>
  451. Some TLS implementations do not send the mandatory close_notify alert on
  452. shutdown. If the application tries to wait for the close_notify alert but the
  453. peer closes the connection without sending it, an error is generated. When this
  454. option is enabled the peer does not need to send the close_notify alert and a
  455. closed connection will be treated as if the close_notify alert was received.
  456. For more information on shutting down a connection, see L<SSL_shutdown(3)>.
  457. =item B<-bugs>
  458. There are several known bugs in SSL and TLS implementations. Adding this
  459. option enables various workarounds.
  460. =item B<-no_tx_cert_comp>
  461. Disables support for sending TLSv1.3 compressed certificates.
  462. =item B<-no_rx_cert_comp>
  463. Disables support for receiving TLSv1.3 compressed certificate.
  464. =item B<-comp>
  465. Enables support for SSL/TLS compression.
  466. This option was introduced in OpenSSL 1.1.0.
  467. TLS compression is not recommended and is off by default as of
  468. OpenSSL 1.1.0. TLS compression can only be used in security level 1 or
  469. lower. From OpenSSL 3.2.0 and above the default security level is 2, so this
  470. option will have no effect without also changing the security level. Use the
  471. B<-cipher> option to change the security level. See L<openssl-ciphers(1)> for
  472. more information.
  473. =item B<-no_comp>
  474. Disables support for SSL/TLS compression.
  475. TLS compression is not recommended and is off by default as of
  476. OpenSSL 1.1.0.
  477. =item B<-brief>
  478. Only provide a brief summary of connection parameters instead of the
  479. normal verbose output.
  480. =item B<-sigalgs> I<sigalglist>
  481. Specifies the list of signature algorithms that are sent by the client.
  482. The server selects one entry in the list based on its preferences.
  483. For example strings, see L<SSL_CTX_set1_sigalgs(3)>
  484. =item B<-curves> I<curvelist>
  485. Specifies the list of supported curves to be sent by the client. The curve is
  486. ultimately selected by the server.
  487. The list of all supported groups includes named EC parameters as well as X25519
  488. and X448 or FFDHE groups, and may also include groups implemented in 3rd-party
  489. providers. For a list of named EC parameters, use:
  490. $ openssl ecparam -list_curves
  491. =item B<-cipher> I<cipherlist>
  492. This allows the TLSv1.2 and below cipher list sent by the client to be modified.
  493. This list will be combined with any TLSv1.3 ciphersuites that have been
  494. configured. Although the server determines which ciphersuite is used it should
  495. take the first supported cipher in the list sent by the client. See
  496. L<openssl-ciphers(1)> for more information.
  497. =item B<-ciphersuites> I<val>
  498. This allows the TLSv1.3 ciphersuites sent by the client to be modified. This
  499. list will be combined with any TLSv1.2 and below ciphersuites that have been
  500. configured. Although the server determines which cipher suite is used it should
  501. take the first supported cipher in the list sent by the client. See
  502. L<openssl-ciphers(1)> for more information. The format for this list is a simple
  503. colon (":") separated list of TLSv1.3 ciphersuite names.
  504. =item B<-starttls> I<protocol>
  505. Send the protocol-specific message(s) to switch to TLS for communication.
  506. I<protocol> is a keyword for the intended protocol. Currently, the only
  507. supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server",
  508. "irc", "postgres", "mysql", "lmtp", "nntp", "sieve" and "ldap".
  509. =item B<-xmpphost> I<hostname>
  510. This option, when used with "-starttls xmpp" or "-starttls xmpp-server",
  511. specifies the host for the "to" attribute of the stream element.
  512. If this option is not specified, then the host specified with "-connect"
  513. will be used.
  514. This option is an alias of the B<-name> option for "xmpp" and "xmpp-server".
  515. =item B<-name> I<hostname>
  516. This option is used to specify hostname information for various protocols
  517. used with B<-starttls> option. Currently only "xmpp", "xmpp-server",
  518. "smtp" and "lmtp" can utilize this B<-name> option.
  519. If this option is used with "-starttls xmpp" or "-starttls xmpp-server",
  520. if specifies the host for the "to" attribute of the stream element. If this
  521. option is not specified, then the host specified with "-connect" will be used.
  522. If this option is used with "-starttls lmtp" or "-starttls smtp", it specifies
  523. the name to use in the "LMTP LHLO" or "SMTP EHLO" message, respectively. If
  524. this option is not specified, then "mail.example.com" will be used.
  525. =item B<-tlsextdebug>
  526. Print out a hex dump of any TLS extensions received from the server.
  527. =item B<-no_ticket>
  528. Disable RFC4507bis session ticket support.
  529. =item B<-sess_out> I<filename>
  530. Output SSL session to I<filename>.
  531. =item B<-sess_in> I<filename>
  532. Load SSL session from I<filename>. The client will attempt to resume a
  533. connection from this session.
  534. =item B<-serverinfo> I<types>
  535. A list of comma-separated TLS Extension Types (numbers between 0 and
  536. 65535). Each type will be sent as an empty ClientHello TLS Extension.
  537. The server's response (if any) will be encoded and displayed as a PEM
  538. file.
  539. =item B<-status>
  540. Sends a certificate status request to the server (OCSP stapling). The server
  541. response (if any) is printed out.
  542. =item B<-alpn> I<protocols>, B<-nextprotoneg> I<protocols>
  543. These flags enable the Enable the Application-Layer Protocol Negotiation
  544. or Next Protocol Negotiation (NPN) extension, respectively. ALPN is the
  545. IETF standard and replaces NPN.
  546. The I<protocols> list is a comma-separated list of protocol names that
  547. the client should advertise support for. The list should contain the most
  548. desirable protocols first. Protocol names are printable ASCII strings,
  549. for example "http/1.1" or "spdy/3".
  550. An empty list of protocols is treated specially and will cause the
  551. client to advertise support for the TLS extension but disconnect just
  552. after receiving ServerHello with a list of server supported protocols.
  553. The flag B<-nextprotoneg> cannot be specified if B<-tls1_3> is used.
  554. =item B<-ct>, B<-noct>
  555. Use one of these two options to control whether Certificate Transparency (CT)
  556. is enabled (B<-ct>) or disabled (B<-noct>).
  557. If CT is enabled, signed certificate timestamps (SCTs) will be requested from
  558. the server and reported at handshake completion.
  559. Enabling CT also enables OCSP stapling, as this is one possible delivery method
  560. for SCTs.
  561. =item B<-ctlogfile>
  562. A file containing a list of known Certificate Transparency logs. See
  563. L<SSL_CTX_set_ctlog_list_file(3)> for the expected file format.
  564. =item B<-keylogfile> I<file>
  565. Appends TLS secrets to the specified keylog file such that external programs
  566. (like Wireshark) can decrypt TLS connections.
  567. =item B<-early_data> I<file>
  568. Reads the contents of the specified file and attempts to send it as early data
  569. to the server. This will only work with resumed sessions that support early
  570. data and when the server accepts the early data.
  571. =item B<-enable_pha>
  572. For TLSv1.3 only, send the Post-Handshake Authentication extension. This will
  573. happen whether or not a certificate has been provided via B<-cert>.
  574. =item B<-use_srtp> I<value>
  575. Offer SRTP key management, where B<value> is a colon-separated profile list.
  576. =item B<-srpuser> I<value>
  577. Set the SRP username to the specified value. This option is deprecated.
  578. =item B<-srppass> I<value>
  579. Set the SRP password to the specified value. This option is deprecated.
  580. =item B<-srp_lateuser>
  581. SRP username for the second ClientHello message. This option is deprecated.
  582. =item B<-srp_moregroups> This option is deprecated.
  583. Tolerate other than the known B<g> and B<N> values.
  584. =item B<-srp_strength> I<number>
  585. Set the minimal acceptable length, in bits, for B<N>. This option is
  586. deprecated.
  587. =item B<-ktls>
  588. Enable Kernel TLS for sending and receiving.
  589. This option was introduced in OpenSSL 3.2.0.
  590. Kernel TLS is off by default as of OpenSSL 3.2.0.
  591. =item B<-tfo>
  592. Enable creation of connections via TCP fast open (RFC7413).
  593. {- $OpenSSL::safe::opt_version_item -}
  594. {- $OpenSSL::safe::opt_name_item -}
  595. {- $OpenSSL::safe::opt_x_item -}
  596. {- $OpenSSL::safe::opt_trust_item -}
  597. {- $OpenSSL::safe::opt_s_item -}
  598. {- $OpenSSL::safe::opt_r_item -}
  599. {- $OpenSSL::safe::opt_provider_item -}
  600. {- $OpenSSL::safe::opt_engine_item -}
  601. {- output_off() if $disabled{"deprecated-3.0"}; "" -}
  602. =item B<-ssl_client_engine> I<id>
  603. Specify engine to be used for client certificate operations.
  604. {- output_on() if $disabled{"deprecated-3.0"}; "" -}
  605. {- $OpenSSL::safe::opt_v_item -}
  606. Verification errors are displayed, for debugging, but the command will
  607. proceed unless the B<-verify_return_error> option is used.
  608. =item B<-enable_server_rpk>
  609. Enable support for receiving raw public keys (RFC7250) from the server.
  610. Use of X.509 certificates by the server becomes optional, and servers that
  611. support raw public keys may elect to use them.
  612. Servers that don't support raw public keys or prefer to use X.509
  613. certificates can still elect to send X.509 certificates as usual.
  614. =item B<-enable_client_rpk>
  615. Enable support for sending raw public keys (RFC7250) to the server.
  616. A raw public key will be sent by the client, if solicited by the server,
  617. provided a suitable key and public certificate pair is configured.
  618. Some servers may nevertheless not request any client credentials,
  619. or may request a certificate.
  620. =item I<host>:I<port>
  621. Rather than providing B<-connect>, the target host and optional port may
  622. be provided as a single positional argument after all options. If neither this
  623. nor B<-connect> are provided, falls back to attempting to connect to
  624. I<localhost> on port I<4433>.
  625. If the host string is an IPv6 address, it must be enclosed in C<[> and C<]>.
  626. =back
  627. =head1 CONNECTED COMMANDS (BASIC)
  628. If a connection is established with an SSL/TLS server then any data received
  629. from the server is displayed and any key presses will be sent to the
  630. server. If end of file is reached then the connection will be closed down.
  631. When used interactively (which means neither B<-quiet> nor B<-ign_eof> have been
  632. given), and neither of B<-adv> or B<-nocommands> are given then "Basic" command
  633. mode is entered. In this mode certain commands are recognized which perform
  634. special operations. These commands are a letter which must appear at the start
  635. of a line. All further data after the initial letter on the line is ignored.
  636. The commands are listed below.
  637. =over 4
  638. =item B<Q>
  639. End the current SSL connection and exit.
  640. =item B<R>
  641. Renegotiate the SSL session (TLSv1.2 and below only).
  642. =item B<C>
  643. Attempt to reconnect to the server using a resumption handshake.
  644. =item B<k>
  645. Send a key update message to the server (TLSv1.3 only)
  646. =item B<K>
  647. Send a key update message to the server and request one back (TLSv1.3 only)
  648. =back
  649. =head1 CONNECTED COMMANDS (ADVANCED)
  650. If B<-adv> has been given then "advanced" command mode is entered. As with basic
  651. mode, if a connection is established with an SSL/TLS server then any data
  652. received from the server is displayed and any key presses will be sent to the
  653. server. If end of file is reached then the connection will be closed down.
  654. Special commands can be supplied by enclosing them in braces, e.g. "{help}" or
  655. "{quit}". These commands can appear anywhere in the text entered into s_client,
  656. but they are not sent to the server. Some commands can take an argument by
  657. ending the command name with ":" and then providing the argument, e.g.
  658. "{keyup:req}". Some commands are only available when certain protocol versions
  659. have been negotiated.
  660. If a newline appears at the end of a line entered into s_client then this is
  661. also sent to the server. If a command appears on a line on its own with no other
  662. text on the same line, then the newline is suppressed and not sent to the
  663. server.
  664. The following commands are recognised.
  665. =over 4
  666. =item B<help>
  667. Prints out summary help text about the available commands.
  668. =item B<quit>
  669. Close the connection to the peer
  670. =item B<reconnect>
  671. Reconnect to the peer and attempt a resumption handshake
  672. =item B<keyup>
  673. Send a Key Update message. TLSv1.3 only. This command takes an optional
  674. argument. If the argument "req" is supplied then the peer is also requested to
  675. update its keys. Otherwise if "noreq" is supplied the the peer is not requested
  676. to update its keys. The default is "req".
  677. =item B<reneg>
  678. Initiate a renegotiation with the server. (D)TLSv1.2 or below only.
  679. =item B<fin>
  680. Indicate FIN on the current stream. QUIC only. Once FIN has been sent any
  681. further text entered for this stream is ignored.
  682. =back
  683. =head1 NOTES
  684. This command can be used to debug SSL servers. To connect to an SSL HTTP
  685. server the command:
  686. openssl s_client -connect servername:443
  687. would typically be used (https uses port 443). If the connection succeeds
  688. then an HTTP command can be given such as "GET /" to retrieve a web page.
  689. If the handshake fails then there are several possible causes, if it is
  690. nothing obvious like no client certificate then the B<-bugs>,
  691. B<-ssl3>, B<-tls1>, B<-no_ssl3>, B<-no_tls1> options can be tried
  692. in case it is a buggy server. In particular you should play with these
  693. options B<before> submitting a bug report to an OpenSSL mailing list.
  694. A frequent problem when attempting to get client certificates working
  695. is that a web client complains it has no certificates or gives an empty
  696. list to choose from. This is normally because the server is not sending
  697. the clients certificate authority in its "acceptable CA list" when it
  698. requests a certificate. By using this command, the CA list can be viewed
  699. and checked. However, some servers only request client authentication
  700. after a specific URL is requested. To obtain the list in this case it
  701. is necessary to use the B<-prexit> option and send an HTTP request
  702. for an appropriate page.
  703. If a certificate is specified on the command line using the B<-cert>
  704. option it will not be used unless the server specifically requests
  705. a client certificate. Therefore, merely including a client certificate
  706. on the command line is no guarantee that the certificate works.
  707. If there are problems verifying a server certificate then the
  708. B<-showcerts> option can be used to show all the certificates sent by the
  709. server.
  710. This command is a test tool and is designed to continue the
  711. handshake after any certificate verification errors. As a result it will
  712. accept any certificate chain (trusted or not) sent by the peer. Non-test
  713. applications should B<not> do this as it makes them vulnerable to a MITM
  714. attack. This behaviour can be changed by with the B<-verify_return_error>
  715. option: any verify errors are then returned aborting the handshake.
  716. The B<-bind> option may be useful if the server or a firewall requires
  717. connections to come from some particular address and or port.
  718. =head2 Note on Non-Interactive Use
  719. When B<s_client> is run in a non-interactive environment (e.g., a cron job or
  720. a script without a valid I<stdin>), it may close the connection prematurely,
  721. especially with TLS 1.3. To prevent this, you can use the B<-ign_eof> flag,
  722. which keeps B<s_client> running even after reaching EOF from I<stdin>.
  723. For example:
  724. openssl s_client -connect <server address>:443 -tls1_3
  725. -sess_out /path/to/tls_session_params_file
  726. -ign_eof </dev/null
  727. However, relying solely on B<-ign_eof> can lead to issues if the server keeps
  728. the connection open, expecting the client to close first. In such cases, the
  729. client may hang indefinitely. This behavior is not uncommon, particularly with
  730. protocols where the server waits for a graceful disconnect from the client.
  731. For example, when connecting to an SMTP server, the session may pause if the
  732. server expects a QUIT command before closing:
  733. $ openssl s_client -brief -ign_eof -starttls smtp
  734. -connect <server address>:25 </dev/null
  735. CONNECTION ESTABLISHED
  736. Protocol version: TLSv1.3
  737. Ciphersuite: TLS_AES_256_GCM_SHA384
  738. ...
  739. 250 CHUNKING
  740. [long pause]
  741. To avoid such hangs, it's better to use an application-level command to
  742. initiate a clean disconnect. For SMTP, you can send a QUIT command:
  743. printf 'QUIT\r\n' | openssl s_client -connect <server address>:25
  744. -starttls smtp -brief -ign_eof
  745. Similarly, for HTTP/1.1 connections, including a `Connection: close` header
  746. ensures the server closes the connection after responding:
  747. printf 'GET / HTTP/1.1\r\nHost: <server address>\r\nConnection: close\r\n\r\n'
  748. | openssl s_client -connect <server address>:443 -brief
  749. These approaches help manage the connection closure gracefully and prevent
  750. hangs caused by the server waiting for the client to initiate the disconnect.
  751. =head1 BUGS
  752. Because this program has a lot of options and also because some of the
  753. techniques used are rather old, the C source for this command is rather
  754. hard to read and not a model of how things should be done.
  755. A typical SSL client program would be much simpler.
  756. The B<-prexit> option is a bit of a hack. We should really report
  757. information whenever a session is renegotiated.
  758. =head1 SEE ALSO
  759. L<openssl(1)>,
  760. L<openssl-sess_id(1)>,
  761. L<openssl-s_server(1)>,
  762. L<openssl-ciphers(1)>,
  763. L<SSL_CONF_cmd(3)>,
  764. L<SSL_CTX_set_max_send_fragment(3)>,
  765. L<SSL_CTX_set_split_send_fragment(3)>,
  766. L<SSL_CTX_set_max_pipelines(3)>,
  767. L<ossl_store-file(7)>
  768. =head1 HISTORY
  769. The B<-no_alt_chains> option was added in OpenSSL 1.1.0.
  770. The B<-name> option was added in OpenSSL 1.1.1.
  771. The B<-certform> option has become obsolete in OpenSSL 3.0.0 and has no effect.
  772. The B<-engine> option was deprecated in OpenSSL 3.0.
  773. The
  774. B<-enable_client_rpk>,
  775. B<-enable_server_rpk>,
  776. B<-no_rx_cert_comp>,
  777. B<-no_tx_cert_comp>,
  778. and B<-tfo>
  779. options were added in OpenSSL 3.2.
  780. =head1 COPYRIGHT
  781. Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.
  782. Licensed under the Apache License 2.0 (the "License"). You may not use
  783. this file except in compliance with the License. You can obtain a copy
  784. in the file LICENSE in the source distribution or at
  785. L<https://www.openssl.org/source/license.html>.
  786. =cut