March 18, 201610 yr OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. Mostly used command option is s_client - SSL/TLS client program 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 can be used to debug SSL servers. To connect to an SSL HTTP server the command: openssl 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. Here are all possible uses of openssl s_client -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. -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. -servername name Set the TLS SNI (Server Name Indication) extension in the ClientHello message. -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. -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. -pass arg the private key password source. For more information about the format of arg see the PASS PHRASE ARGUMENTS section in openssl. -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 -no-CApath Do not load the trusted CA certificates from the default directory location -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. -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. -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. -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. -state prints out the SSL session states. -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. OpenSSL needs to be compiled with enable-ssl-trace for this option to work. -msgfile file to send output of -msg or -trace to, default standard output. -nbio_test tests non-blocking I/O -nbio turns on non-blocking I/O -crlf this option translated a line feed from the terminal into CR+LF as required by some servers. -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. -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. -psk_identity identity Use the PSK identity identity when using a PSK cipher suite. -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. -ssl3, -tls1, -tls1_1, -tls1_2, -no_ssl3, -no_tls1, -no_tls1_1, -no_tls1_2 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. -dtls, -dtls1, -dtls1_2 These options make s_client use DTLS protocols instead of TLS. With -dtls, s_client will negotiate any supported DTLS protcol version, whilst -dtls1 and -dtls1_2 will only support DTLS1.0 and DTLS1.2 respectively. -fallback_scsv Send TLS_FALLBACK_SCSV in the ClientHello. -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). -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 SSL_CTX_set_split_send_fragment for further information. -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 suiteable ciphersuite has been negotiated. The default value is 1. See SSL_CTX_set_max_pipelines for further information. -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 SSL_CTX_set_default_read_buffer_len for further information). -bugs there are several known bug in SSL and TLS implementations. Adding this option enables various workarounds. -comp Enables support for SSL/TLS compression. This option was introduced in OpenSSL 1.1.0. TLS compression is not recommended and is off by default as of OpenSSL 1.1.0. -no_comp Disables support for SSL/TLS compression. TLS compression is not recommended and is off by default as of OpenSSL 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. -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." -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. -tlsextdebug print out a hex dump of any TLS extensions received from the server. -no_ticket disable RFC4507bis session ticket support. -sess_out filename output SSL session to filename -sess_in sess.pem load SSL session from filename. The client will attempt to resume a connection from this session. -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. -rand file(s) a file or files containing random data used to seed the random number generator, or an EGD socket (see RAND_egd). Multiple files can be specified separated by a OS-dependent character. The separator is ; for MS-Windows, , for OpenVMS, and : for all others. -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. -status sends a certificate status request to the server (OCSP stapling). The server response (if any) is printed out. -nextprotoneg protocols enable Next Protocol Negotiation TLS extension and provide a list of 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. -noct|requestct|requirect Use one of these three options to control whether Certificate Transparency (CT) is disabled (-noct), enabled but not enforced (-requestct), or enabled and enforced (-requirect). If CT is enabled, signed certificate timestamps (SCTs) will be requested from the server and invalid SCTs will cause the connection to be aborted. If CT is enforced, at least one valid SCT from a recognised CT log (see -ctlogfile) will be required or the connection will be aborted. Enabling CT also enables OCSP stapling, as this is one possible delivery method for SCTs. -ctlogfile A file containing a list of known Certificate Transparency logs.
March 18, 201610 yr Author Some examples of how to use openssl s_client -connect vipip:portnumber Example: openssl s_client -connect 10.46.88.166:8443 openssl s_client -host -port Example openssl s_client -host 10.40.88.95 -port 21003 openssl s_client -connect www14.software.ibm.com:443 > cert Show Certs openssl s_client -showcerts -connect www.example.com:443 Test TLS1.2 openssl s_client -connect www.example.com:443 -tls1_2 Test SSL2 openssl s_client -connect www.example.com:443 -ssl2 Test SSL3 openssl s_client -connect www.example.com:443 -ssl3 Test Cipher Test for TLS1.2 (256) openssl s_client -connect www.example.com:443 -tls1 -cipher AES256-SHA128 Test for TLS1.2 (128) openssl s_client -connect www.example.com:443 -tls1 -cipher AES128-SHA256 Test for TLS1 (256) openssl s_client -connect www.example.com:443 -tls1 -cipher AES256-SHA Test for TLS1 (256) openssl s_client -connect www.example.com:443 -tls1 -cipher DHE-RSA-AES256-SHA Some other saved commands used to validate the certificate The following will test for TLSv1 echo -n | openssl s_client -tls1 -connect 10.46.88.76:6181 This will test TLSv1.1 echo -n | openssl s_client -tls1_1 -connect 10.46.88.76:6181 This will test TLSv1.2 echo -n | openssl s_client -tls1_2 -connect 10.46.88.76:6181 The following will test if a certificate is applied openssl s_client -host 10.40.88.95 -port 21003 This command is used to tell you the expiration date of the cert echo | openssl s_client -connect 10.40.88.120:443 2>/dev/null | openssl x509 -noout -dates
Create an account or sign in to comment