- NAME
- SYNOPSIS
- DESCRIPTION
- OPTIONS
- CONNECTED COMMANDS
- NOTES
- BUGS
- SEE ALSO
- HISTORY
- COPYRIGHT

# NAME

s_client - SSL/TLS client program

# SYNOPSIS

gmssl s_client [-help] [-connect host:port] [-proxy host:port] [-unix path] [-4] [-6] [-servername name] [-verify depth] [-verify_return_error] [-cert filename] [-certform DER|PEM] [-key filename] [-keyform DER|PEM] [-pass arg] [-CApath directory] [-CAfile filename] [-no-CAfile] [-no-CApath] [-dane_tlsa_domain domain] [-dane_tlsa_rrdata rrdata] [-dane_ee_no_namechecks] [-attime timestamp] [-check_ss_sig] [-crl_check] [-crl_check_all] [-explicit_policy] [-extended_crl] [-ignore_critical] [-inhibit_any] [-inhibit_map] [-no_check_time] [-partial_chain] [-policy arg] [-policy_check] [-policy_print] [-purpose purpose] [-suiteB_128] [-suiteB_128_only] [-suiteB_192] [-trusted_first] [-no_alt_chains] [-use_deltas] [-auth_level num] [-verify_depth num] [-verify_email email] [-verify_hostname hostname] [-verify_ip ip] [-verify_name name] [-x509_strict] [-reconnect] [-showcerts] [-debug] [-msg] [-nbio_test] [-state] [-nbio] [-crlf] [-ign_eof] [-no_ign_eof] [-quiet] [-ssl3] [-tls1] [-tls1_1] [-tls1_2] [-tls1_3] [-no_ssl3] [-no_tls1] [-no_tls1_1] [-no_tls1_2] [-no_tls1_3] [-dtls] [-dtls1] [-dtls1_2] [-fallback_scsv] [-async] [-split_send_frag] [-max_pipelines] [-read_buf] [-bugs] [-comp] [-no_comp] [-cipher cipherlist] [-serverpref] [-starttls protocol] [-xmpphost hostname] [-engine id] [-tlsextdebug] [-no_ticket] [-sess_out filename] [-sess_in filename] [-rand file(s)] [-serverinfo types] [-status] [-alpn protocols] [-nextprotoneg protocols] [-ct|noct] [-ctlogfile]

# DESCRIPTION

The s_client command implements a generic SSL/TLS client which connects to a remote host using SSL/TLS. It is a very useful diagnostic tool for SSL servers.

s_client命令实现使用SSL / TLS连接到远程主机的通用SSL / TLS客户端。 它是SSL服务器非常有用的诊断工具。

# OPTIONS

In addition to the options below the s_client utility also supports the common and client only options documented in the in the "Supported Command Line Commands" section of the -help

  Print out a usage message.

  输出使用信息。

-connect host:port

  This specifies the host and optional port to connect to. If not specified then an attempt is made to connect to the local host on port 4433.

  这指定要连接的主机和可选端口。 如果未指定，则尝试连接到端口4433上的本地主机。

-proxy host:port

  When used with the -connect flag, the program uses the host and port specified with this flag and issues an HTTP CONNECT command to connect to the desired server.

  当与-connect标志一起使用时，程序使用由该标志指定的主机和端口，并发出HTTP CONNECT命令连接到所需的服务器。

-unix path

  Connect over the specified Unix-domain socket.

  连接指定的Unix域套接字。

-4

  Use IPv4 only.

  仅使用IPv4。

-6

  Use IPv6 only.

  仅使用IPv6.

-servername name

  Set the TLS SNI (Server Name Indication) extension in the ClientHello message.

  在ClientHello消息中设置TLS SNI（服务器名称指示）扩展。

-cert certname

  The certificate to use, if one is requested by the server. The default is not to use a certificate.

  要使用的证书，如果是服务器请求的。 默认情况下不使用证书。

-certform format

  The certificate format to use: DER or PEM. PEM is the default.

  使用的证书格式：DER或PEM。 PEM是默认值。

-key keyfile

  The private key to use. If not specified then the certificate file will be used.

  使用私钥。 如果未指定，则将使用证书文件。

-keyform format

  The private format to use: DER or PEM. PEM is the default.

  要使用的私有格式：DER或PEM。 PEM是默认值。

-pass arg

  the private key password source. For more information about the format of arg see the PASS PHRASE ARGUMENTS section in -verify depth

  The verify depth to use. This specifies the maximum length of the server certificate chain and turns on server certificate verification. Currently the verify operation continues after errors so all the problems with a certificate chain can be seen. As a side effect the connection will never fail due to a server certificate verify failure.

  验证使用深度。 这指定服务器证书链的最大长度，并打开服务器证书验证。 目前，验证操作在错误之后继续，所以可以看到证书链中的所有问题。 作为副作用，由于服务器证书验证失败，连接永远不会失败。

-verify_return_error

  Return verification errors instead of continuing. This will typically abort the handshake with a fatal error.

  返回验证错误，而不是继续。 这通常会以致命错误中止握手。

-CApath directory

  The directory to use for server certificate verification. This directory must be in "hash format", see verify for more information. These are also used when building the client certificate chain.

  用于服务器证书验证的目录。 此目录必须为“哈希格式”，请参阅验证更多信息。 这些也在构建客户端证书链时使用。

-CAfile file

  A file containing trusted certificates to use during server authentication and to use when attempting to build the client certificate chain.

  包含在服务器认证期间使用并在尝试构建客户端证书链时使用的可信证书的文件。

-no-CAfile

  Do not load the trusted CA certificates from the default file location

  不要从默认文件位置加载受信任的CA证书

-no-CApath

  Do not load the trusted CA certificates from the default directory location

  不要从默认目录位置加载受信任的CA证书

-dane_tlsa_domain domain

  Enable RFC6698/RFC7671 DANE TLSA authentication and specify the TLSA base domain which becomes the default SNI hint and the primary reference identifier for hostname checks. This must be used in combination with at least one instance of the -dane_tlsa_rrdata option below.

  When DANE authentication succeeds, the diagnostic output will include the lowest (closest to 0) depth at which a TLSA record authenticated a chain certificate. When that TLSA record is a "2 1 0" trust anchor public key that signed (rather than matched) the top-most certificate of the chain, the result is reported as "TA public key verified". Otherwise, either the TLSA record "matched TA certificate" at a positive depth or else "matched EE certificate" at depth 0.

  启用RFC6698 / RFC7671 DANE TLSA身份验证，并指定成为默认SNI提示的TLSA基本域和主机名检查的主参考标识符。 这必须与以下-dane_tlsa_rrdata选项的至少一个实例结合使用。

  当DANE认证成功时，诊断输出将包括TLSA记录认证链式证书的最低（最接近0）深度。 当该TLSA记录是一个“2 1 0”信任锚公钥，该信任锚公钥是签名（而不是匹配）链中最顶层的证书， 结果被报告为“TA公钥验证”。 否则，TLSA记录“匹配的TA证书”在深度为深度，否则“匹配的EE证书”在深度0。

-dane_tlsa_rrdata rrdata

  Use one or more times to specify the RRDATA fields of the DANE TLSA RRset associated with the target service. The rrdata value is specied in "presentation form", that is four whitespace separated fields that specify the usage, selector, matching type and associated data, with the last of these encoded in hexadecimal. Optional whitespace is ignored in the associated data field. For example:

  使用一次或多次来指定与目标服务相关联的DANE TLSA RRset的RRDATA字段。 rrdata值以“表示形式”指定，即指定使用，选择器，匹配类型和关联数据的 四个空白分隔字段，其中最后一个以十六进制编码。 可选的空格在关联的数据字段中被忽略。 例如：

        $ gmssl s_client -brief -starttls smtp \
          -connect smtp.example.com:25 \
          -dane_tlsa_domain smtp.example.com \
          -dane_tlsa_rrdata "2 1 1
            B111DD8A1C2091A89BD4FD60C57F0716CCE50FEEFF8137CDBEE0326E 02CF362B" \
          -dane_tlsa_rrdata "2 1 1
            60B87575447DCBA2A36B7D11AC09FB24A9DB406FEE12D2CC90180517 616E8A18"
        ...
        Verification: OK
        Verified peername: smtp.example.com
        DANE TLSA 2 1 1 ...ee12d2cc90180517616e8a18 matched TA certificate at depth 1
        ...

-dane_ee_no_namechecks

  This disables server name checks when authenticating via DANE-EE(3) TLSA records. For some applications, primarily web browsers, it is not safe to disable name checks due to "unknown key share" attacks, in which a malicious server can convince a client that a connection to a victim server is instead a secure connection to the malicious server. The malicious server may then be able to violate cross-origin scripting restrictions. Thus, despite the text of RFC7671, name checks are by default enabled for DANE-EE(3) TLSA records, and can be disabled in applications where it is safe to do so. In particular, SMTP and XMPP clients should set this option as SRV and MX records already make it possible for a remote domain to redirect client connections to any server of its choice, and in any case SMTP and XMPP clients do not execute scripts downloaded from remote servers.

  当通过DANE-EE（3）TLSA记录进行身份验证时，这将禁用服务器名称检查。 对于某些应用程序（主要是Web浏览器），由于“未知密钥共享”攻击，禁用名称检查是 不安全的，恶意服务器可以说服客户端与受害者服务器的连接而不是与恶意服务器的安全 连接。 恶意服务器可能能够违反跨原始脚本限制。 因此，尽管RFC7671的文本，默认情 况下，对DANE-EE（3）TLSA记录启用名称检查，并且可以在安全的应用程序中禁用名称检查。 特别是，SMTP和XMPP客户端应该将此选项设置为SRV和MX记录，使远程域可以将客户端连接 重定向到所选的任何服务器，无论如何，SMTP和XMPP客户端不会执行从远程服务器下载的脚本服务器。

-attime, -check_ss_sig, -crl_check, -crl_check_all, -explicit_policy, -extended_crl, -ignore_critical, -inhibit_any, -inhibit_map, -no_alt_chains, -no_check_time, -partial_chain, -policy, -policy_check, -policy_print, -purpose, -suiteB_128, -suiteB_128_only, -suiteB_192, -trusted_first, -use_deltas, -auth_level, -verify_depth, -verify_email, -verify_hostname, -verify_ip, -verify_name, -x509_strict

  Set various certificate chain validation options. See the -reconnect

  reconnects to the same server 5 times using the same session ID, this can be used as a test that session caching is working.

  使用相同的会话ID重新连接到相同的服务器5次，这可以用作会话缓存正在工作的测试。

-showcerts

  display the whole server certificate chain: normally only the server certificate itself is displayed.

  显示整个服务器证书链：通常只显示服务器证书本身。

-prexit

  print session information when the program exits. This will always attempt to print out information even if the connection fails. Normally information will only be printed out once if the connection succeeds. This option is useful because the cipher in use may be renegotiated or the connection may fail because a client certificate is required or is requested only after an attempt is made to access a certain URL. Note: the output produced by this option is not always accurate because a connection might never have been established.

  当程序退出时打印会话信息。 即使连接失败，它也将始终尝试打印出信息。 通常， 如果连接成功，信息将仅打印一次。 此选项非常有用，因为正在使用的密码可能被 重新协商，或连接可能会失败，因为客户端证书是必需的，或仅在尝试访问某个URL 后才被请求。 注意：此选项生成的输出并不总是准确的，因为连接可能永远不会建立。

-state

  prints out the SSL session states.

  打印出SSL会话状态。

-debug

  print extensive debugging information including a hex dump of all traffic.

  打印广泛的调试信息，包括所有流量的十六进制转储。

-msg

  show all protocol messages with hex dump.

  显示所有具有十六进制转储的协议消息。

-trace

  show verbose trace output of protocol messages. GmSSL needs to be compiled with enable-ssl-trace for this option to work.

  显示协议消息的详细跟踪输出。 需要使用enable-ssl-trace编译GmSSL才能使此选项生效。

-msgfile

  file to send output of -msg or -trace to, default standard output.

  文件将-msg或-trace的输出发送到，默认标准输出。

-nbio_test

  tests non-blocking I/O

  测试非阻塞I / O

-nbio

  turns on non-blocking I/O

  打开非阻塞I / O

-crlf

  this option translated a line feed from the terminal into CR+LF as required by some servers.

  该选项根据某些服务器的要求将终端转换为CR + LF。

-ign_eof

  inhibit shutting down the connection when end of file is reached in the input.

  禁止在输入端到达文件结束时关闭连接。

-quiet

  inhibit printing of session and certificate information. This implicitly turns on -ign_eof as well.

  禁止打印会话和证书信息。 这也隐含地打开-ign_eof。

-no_ign_eof

  shut down the connection when end of file is reached in the input. Can be used to override the implicit -ign_eof after -quiet.

  在输入端到达文件结束时关闭连接。 可以用于在-quiet之后覆盖隐式的-ign_eof。

-psk_identity identity

  Use the PSK identity identity when using a PSK cipher suite.

  使用PSK密码套件时使用PSK身份标识。

-psk key

  Use the PSK key key when using a PSK cipher suite. The key is given as a hexadecimal number without leading 0x, for example -psk 1a2b3c4d.

  使用PSK密码套件时，请使用PSK密钥。 密钥以十六进制数字的形式给出，不带前缀0x，例如-psk 1a2b3c4d。

-ssl3, -tls1, -tls1_1, -tls1_2, -tls1_3, -no_ssl3, -no_tls1, -no_tls1_1, -no_tls1_2, -no_tls1_3

  These options require or disable the use of the specified SSL or TLS protocols. By default s_client will negotiate the highest mutually supported protocol version. When a specific TLS version is required, only that version will be offered to and accepted from the server.

  这些选项需要或禁止使用指定的SSL或TLS协议。 默认情况下，s_client将协商最高相互 支持的协议版本。 当需要特定的TLS版本时，只有该版本将被提供给服务器并从服务器接受。

-dtls, -dtls1, -dtls1_2

  These options make s_client use DTLS protocols instead of TLS. With -dtls, s_client will negotiate any supported DTLS protocol version, whilst -dtls1 and -dtls1_2 will only support DTLS1.0 and DTLS1.2 respectively.

  这些选项使s_client使用DTLS协议而不是TLS。 使用-dtls，s_client将协商任何支持的 DTLS协议版本，而-dtls1和-dtls1_2将分别仅支持DTLS1.0和DTLS1.2。

-fallback_scsv

  Send TLS_FALLBACK_SCSV in the ClientHello.

  在ClientHello中发送TLS_FALLBACK_SCSV。

-async

  switch on asynchronous mode. Cryptographic operations will be performed asynchronously. This will only have an effect if an asynchronous capable engine is also used via the -engine option. For test purposes the dummy async engine (dasync) can be used (if available).

  开启异步模式。 加密操作将被异步执行。 只有通过-engine选项也可以使用异步的引擎， 这只会产生影响。 为了测试目的，可以使用虚拟异步引擎（dasync）（如果可用）。

-split_send_frag int

  The size used to split data for encrypt pipelines. If more data is written in one go than this value then it will be split into multiple pipelines, up to the maximum number of pipelines defined by max_pipelines. This only has an effect if a suitable ciphersuite has been negotiated, an engine that supports pipelining has been loaded, and max_pipelines is greater than 1. See -max_pipelines int

  The maximum number of encrypt/decrypt pipelines to be used. This will only have an effect if an engine has been loaded that supports pipelining (e.g. the dasync engine) and a suitable ciphersuite has been negotiated. The default value is 1. See -read_buf int

  The default read buffer size to be used for connections. This will only have an effect if the buffer size is larger than the size that would otherwise be used and pipelining is in use (see -bugs

  there are several known bug in SSL and TLS implementations. Adding this option enables various workarounds.

  SSL和TLS实现中有几个已知的错误。 添加此选项可以启用各种解决方法。

-comp

  Enables support for SSL/TLS compression. This option was introduced in GmSSL 1.1.0. TLS compression is not recommended and is off by default as of GmSSL 1.1.0.

  支持SSL / TLS压缩。 此选项在GmSSL 1.1.0中引入。 不推荐使用TLS压缩， 默认情况下，GmSSL 1.1.0关闭。

-no_comp

  Disables support for SSL/TLS compression. TLS compression is not recommended and is off by default as of GmSSL 1.1.0.

  禁用对SSL / TLS压缩的支持。 不推荐使用TLS压缩，默认情况下，GmSSL 1.1.0关闭。

-brief

  only provide a brief summary of connection parameters instead of the normal verbose output.

  只提供连接参数的简要摘要，而不是正常的详细输出。

-cipher cipherlist

  this allows the cipher list sent by the client to be modified. Although the server determines which cipher suite is used it should take the first supported cipher in the list sent by the client. See the ciphers command for more information.

  这允许客户端发送的密码列表被修改。 虽然服务器确定使用哪个密码套件， 但它应该在客户端发送的列表中使用第一个支持的密码。 有关详细信息，请参阅ciphers命令。

-starttls protocol

  send the protocol-specific message(s) to switch to TLS for communication. protocol is a keyword for the intended protocol. Currently, the only supported keywords are "smtp", "pop3", "imap", "ftp", "xmpp", "xmpp-server", and "irc."

  发送特定于协议的消息切换到TLS进行通信。 协议是目标协议的关键字。 目前， 唯一支持的关键字是“smtp”，“pop3”，“imap”，“ftp”，“xmpp”，“xmpp-server”和“irc”。

-xmpphost hostname

  This option, when used with "-starttls xmpp" or "-starttls xmpp-server", specifies the host for the "to" attribute of the stream element. If this option is not specified, then the host specified with "-connect" will be used.

  此选项与“-starttls xmpp”或“-starttls xmpp-server”一起使用时，指定流元素 “to”属性的主机。 如果未指定此选项，则将使用“-connect”指定的主机。

-tlsextdebug

  print out a hex dump of any TLS extensions received from the server.

  打印从服务器接收的任何TLS扩展的十六进制转储。

-no_ticket

  disable RFC4507bis session ticket support.

  禁用RFC4507bis会话票证支持。

-sess_out filename

  output SSL session to filename

  输出SSL会话到filename

-sess_in sess.pem

  load SSL session from filename. The client will attempt to resume a connection from this session.

  从filename加载SSL会话。 客户端将尝试从此会话恢复连接。

-engine id

  specifying an engine (by its unique id string) will cause s_client to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms.

  指定引擎（通过其唯一的id字符串）将导致s_client尝试获取对指定引擎的功能引用，从而在需要时对其进行初始化。 然后，引擎将被设置为所有可用算法的默认值。

-rand file(s)

  a file or files containing random data used to seed the random number generator, or an EGD socket (see -serverinfo types

  a list of comma-separated TLS Extension Types (numbers between 0 and 65535). Each type will be sent as an empty ClientHello TLS Extension. The server's response (if any) will be encoded and displayed as a PEM file.

  逗号分隔的TLS扩展类型列表（0到65535之间的数字）。 每个类型将作为一个空的ClientHello TLS扩展发送。 服务器的响应（如果有）将被编码并显示为PEM文件。

-status

  sends a certificate status request to the server (OCSP stapling). The server response (if any) is printed out.

  向服务器发送证书状态请求（OCSP装订）。 打印出服务器响应（如果有）。

-alpn protocols, -nextprotoneg protocols

  these flags enable the Enable the Application-Layer Protocol Negotiation or Next Protocol Negotiation extension, respectively. ALPN is the IETF standard and replaces NPN. The protocols list is a comma-separated protocol names that the client should advertise support for. The list should contain most wanted protocols first. Protocol names are printable ASCII strings, for example "http/1.1" or "spdy/3". Empty list of protocols is treated specially and will cause the client to advertise support for the TLS extension but disconnect just after receiving ServerHello with a list of server supported protocols.

  这些标志分别启用启用应用层协议协商协议或下一协议协议扩展。 ALPN是IETF标准，替代NPN。 协议列表是客户端应该广告支持的逗号分隔的协议名称。 该列表应该包含最需要的协议。 协议名称是可打印的ASCII字符串，例如“http / 1.1”或“spdy / 3”。 协议的空列表被特别处理，并且将导致客户端向TLS扩展发布支持，但是在使用服务器支持的协议列表接收ServerHello之后断开连接。

-ct|noct

  Use one of these two options to control whether Certificate Transparency (CT) is enabled (-ct) or disabled (-noct). If CT is enabled, signed certificate timestamps (SCTs) will be requested from the server and reported at handshake completion.

  Enabling CT also enables OCSP stapling, as this is one possible delivery method for SCTs.

  使用这两个选项之一来控制是否启用证书透明度（CT）或禁用（-noct）。 如果启用CT，将从服务器请求签名的证书时间戳（SCT），并在握手完成时报告。

  启用CT还可以实现OCSP装订，因为这是SCT的一种可能的传送方式。

-ctlogfile

  A file containing a list of known Certificate Transparency logs. See CONNECTED COMMANDS

  If a connection is established with an SSL server then any data received from the server is displayed and any key presses will be sent to the server. When used interactively (which means neither -quiet nor -ign_eof have been given), the session will be renegotiated if the line begins with an R, and if the line begins with a Q or if end of file is reached, the connection will be closed down.

  # NOTES

  s_client can be used to debug SSL servers. To connect to an SSL HTTP server the command:

       gmssl s_client -connect servername:443

  would typically be used (https uses port 443). If the connection succeeds then an HTTP command can be given such as "GET /" to retrieve a web page.

  If the handshake fails then there are several possible causes, if it is nothing obvious like no client certificate then the -bugs, -ssl3, -tls1, -no_ssl3, -no_tls1 options can be tried in case it is a buggy server. In particular you should play with these options before submitting a bug report to an GmSSL mailing list.

  A frequent problem when attempting to get client certificates working is that a web client complains it has no certificates or gives an empty list to choose from. This is normally because the server is not sending the clients certificate authority in its "acceptable CA list" when it requests a certificate. By using s_client the CA list can be viewed and checked. However some servers only request client authentication after a specific URL is requested. To obtain the list in this case it is necessary to use the -prexit option and send an HTTP request for an appropriate page.

  If a certificate is specified on the command line using the -cert option it will not be used unless the server specifically requests a client certificate. Therefor merely including a client certificate on the command line is no guarantee that the certificate works.

  If there are problems verifying a server certificate then the -showcerts option can be used to show the whole chain.

  The s_client utility is a test tool and is designed to continue the handshake after any certificate verification errors. As a result it will accept any certificate chain (trusted or not) sent by the peer. None test applications should not do this as it makes them vulnerable to a MITM attack. This behaviour can be changed by with the -verify_return_error option: any verify errors are then returned aborting the handshake.

  # BUGS

  Because this program has a lot of options and also because some of the techniques used are rather old, the C source of s_client is rather hard to read and not a model of how things should be done. A typical SSL client program would be much simpler.

  The -prexit option is a bit of a hack. We should really report information whenever a session is renegotiated.

  # SEE ALSO

  sess_id(1), ciphers(1)

  # HISTORY

  The -no_alt_chains options was first added to GmSSL 1.1.0.

  # COPYRIGHT

  Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.

  Licensed under the GmSSL license (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.