1*2175Sjp161948 2*2175Sjp161948=pod 3*2175Sjp161948 4*2175Sjp161948=head1 NAME 5*2175Sjp161948 6*2175Sjp161948s_client - SSL/TLS client program 7*2175Sjp161948 8*2175Sjp161948=head1 SYNOPSIS 9*2175Sjp161948 10*2175Sjp161948B<openssl> B<s_client> 11*2175Sjp161948[B<-connect host:port>] 12*2175Sjp161948[B<-verify depth>] 13*2175Sjp161948[B<-cert filename>] 14*2175Sjp161948[B<-certform DER|PEM>] 15*2175Sjp161948[B<-key filename>] 16*2175Sjp161948[B<-keyform DER|PEM>] 17*2175Sjp161948[B<-pass arg>] 18*2175Sjp161948[B<-CApath directory>] 19*2175Sjp161948[B<-CAfile filename>] 20*2175Sjp161948[B<-reconnect>] 21*2175Sjp161948[B<-pause>] 22*2175Sjp161948[B<-showcerts>] 23*2175Sjp161948[B<-debug>] 24*2175Sjp161948[B<-msg>] 25*2175Sjp161948[B<-nbio_test>] 26*2175Sjp161948[B<-state>] 27*2175Sjp161948[B<-nbio>] 28*2175Sjp161948[B<-crlf>] 29*2175Sjp161948[B<-ign_eof>] 30*2175Sjp161948[B<-quiet>] 31*2175Sjp161948[B<-ssl2>] 32*2175Sjp161948[B<-ssl3>] 33*2175Sjp161948[B<-tls1>] 34*2175Sjp161948[B<-no_ssl2>] 35*2175Sjp161948[B<-no_ssl3>] 36*2175Sjp161948[B<-no_tls1>] 37*2175Sjp161948[B<-bugs>] 38*2175Sjp161948[B<-cipher cipherlist>] 39*2175Sjp161948[B<-starttls protocol>] 40*2175Sjp161948[B<-engine id>] 41*2175Sjp161948[B<-rand file(s)>] 42*2175Sjp161948 43*2175Sjp161948=head1 DESCRIPTION 44*2175Sjp161948 45*2175Sjp161948The B<s_client> command implements a generic SSL/TLS client which connects 46*2175Sjp161948to a remote host using SSL/TLS. It is a I<very> useful diagnostic tool for 47*2175Sjp161948SSL servers. 48*2175Sjp161948 49*2175Sjp161948=head1 OPTIONS 50*2175Sjp161948 51*2175Sjp161948=over 4 52*2175Sjp161948 53*2175Sjp161948=item B<-connect host:port> 54*2175Sjp161948 55*2175Sjp161948This specifies the host and optional port to connect to. If not specified 56*2175Sjp161948then an attempt is made to connect to the local host on port 4433. 57*2175Sjp161948 58*2175Sjp161948=item B<-cert certname> 59*2175Sjp161948 60*2175Sjp161948The certificate to use, if one is requested by the server. The default is 61*2175Sjp161948not to use a certificate. 62*2175Sjp161948 63*2175Sjp161948=item B<-certform format> 64*2175Sjp161948 65*2175Sjp161948The certificate format to use: DER or PEM. PEM is the default. 66*2175Sjp161948 67*2175Sjp161948=item B<-key keyfile> 68*2175Sjp161948 69*2175Sjp161948The private key to use. If not specified then the certificate file will 70*2175Sjp161948be used. 71*2175Sjp161948 72*2175Sjp161948=item B<-keyform format> 73*2175Sjp161948 74*2175Sjp161948The private format to use: DER or PEM. PEM is the default. 75*2175Sjp161948 76*2175Sjp161948=item B<-pass arg> 77*2175Sjp161948 78*2175Sjp161948the private key password source. For more information about the format of B<arg> 79*2175Sjp161948see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 80*2175Sjp161948 81*2175Sjp161948=item B<-verify depth> 82*2175Sjp161948 83*2175Sjp161948The verify depth to use. This specifies the maximum length of the 84*2175Sjp161948server certificate chain and turns on server certificate verification. 85*2175Sjp161948Currently the verify operation continues after errors so all the problems 86*2175Sjp161948with a certificate chain can be seen. As a side effect the connection 87*2175Sjp161948will never fail due to a server certificate verify failure. 88*2175Sjp161948 89*2175Sjp161948=item B<-CApath directory> 90*2175Sjp161948 91*2175Sjp161948The directory to use for server certificate verification. This directory 92*2175Sjp161948must be in "hash format", see B<verify> for more information. These are 93*2175Sjp161948also used when building the client certificate chain. 94*2175Sjp161948 95*2175Sjp161948=item B<-CAfile file> 96*2175Sjp161948 97*2175Sjp161948A file containing trusted certificates to use during server authentication 98*2175Sjp161948and to use when attempting to build the client certificate chain. 99*2175Sjp161948 100*2175Sjp161948=item B<-reconnect> 101*2175Sjp161948 102*2175Sjp161948reconnects to the same server 5 times using the same session ID, this can 103*2175Sjp161948be used as a test that session caching is working. 104*2175Sjp161948 105*2175Sjp161948=item B<-pause> 106*2175Sjp161948 107*2175Sjp161948pauses 1 second between each read and write call. 108*2175Sjp161948 109*2175Sjp161948=item B<-showcerts> 110*2175Sjp161948 111*2175Sjp161948display the whole server certificate chain: normally only the server 112*2175Sjp161948certificate itself is displayed. 113*2175Sjp161948 114*2175Sjp161948=item B<-prexit> 115*2175Sjp161948 116*2175Sjp161948print session information when the program exits. This will always attempt 117*2175Sjp161948to print out information even if the connection fails. Normally information 118*2175Sjp161948will only be printed out once if the connection succeeds. This option is useful 119*2175Sjp161948because the cipher in use may be renegotiated or the connection may fail 120*2175Sjp161948because a client certificate is required or is requested only after an 121*2175Sjp161948attempt is made to access a certain URL. Note: the output produced by this 122*2175Sjp161948option is not always accurate because a connection might never have been 123*2175Sjp161948established. 124*2175Sjp161948 125*2175Sjp161948=item B<-state> 126*2175Sjp161948 127*2175Sjp161948prints out the SSL session states. 128*2175Sjp161948 129*2175Sjp161948=item B<-debug> 130*2175Sjp161948 131*2175Sjp161948print extensive debugging information including a hex dump of all traffic. 132*2175Sjp161948 133*2175Sjp161948=item B<-msg> 134*2175Sjp161948 135*2175Sjp161948show all protocol messages with hex dump. 136*2175Sjp161948 137*2175Sjp161948=item B<-nbio_test> 138*2175Sjp161948 139*2175Sjp161948tests non-blocking I/O 140*2175Sjp161948 141*2175Sjp161948=item B<-nbio> 142*2175Sjp161948 143*2175Sjp161948turns on non-blocking I/O 144*2175Sjp161948 145*2175Sjp161948=item B<-crlf> 146*2175Sjp161948 147*2175Sjp161948this option translated a line feed from the terminal into CR+LF as required 148*2175Sjp161948by some servers. 149*2175Sjp161948 150*2175Sjp161948=item B<-ign_eof> 151*2175Sjp161948 152*2175Sjp161948inhibit shutting down the connection when end of file is reached in the 153*2175Sjp161948input. 154*2175Sjp161948 155*2175Sjp161948=item B<-quiet> 156*2175Sjp161948 157*2175Sjp161948inhibit printing of session and certificate information. This implicitly 158*2175Sjp161948turns on B<-ign_eof> as well. 159*2175Sjp161948 160*2175Sjp161948=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> 161*2175Sjp161948 162*2175Sjp161948these options disable the use of certain SSL or TLS protocols. By default 163*2175Sjp161948the initial handshake uses a method which should be compatible with all 164*2175Sjp161948servers and permit them to use SSL v3, SSL v2 or TLS as appropriate. 165*2175Sjp161948 166*2175Sjp161948Unfortunately there are a lot of ancient and broken servers in use which 167*2175Sjp161948cannot handle this technique and will fail to connect. Some servers only 168*2175Sjp161948work if TLS is turned off with the B<-no_tls> option others will only 169*2175Sjp161948support SSL v2 and may need the B<-ssl2> option. 170*2175Sjp161948 171*2175Sjp161948=item B<-bugs> 172*2175Sjp161948 173*2175Sjp161948there are several known bug in SSL and TLS implementations. Adding this 174*2175Sjp161948option enables various workarounds. 175*2175Sjp161948 176*2175Sjp161948=item B<-cipher cipherlist> 177*2175Sjp161948 178*2175Sjp161948this allows the cipher list sent by the client to be modified. Although 179*2175Sjp161948the server determines which cipher suite is used it should take the first 180*2175Sjp161948supported cipher in the list sent by the client. See the B<ciphers> 181*2175Sjp161948command for more information. 182*2175Sjp161948 183*2175Sjp161948=item B<-starttls protocol> 184*2175Sjp161948 185*2175Sjp161948send the protocol-specific message(s) to switch to TLS for communication. 186*2175Sjp161948B<protocol> is a keyword for the intended protocol. Currently, the only 187*2175Sjp161948supported keywords are "smtp" and "pop3". 188*2175Sjp161948 189*2175Sjp161948=item B<-engine id> 190*2175Sjp161948 191*2175Sjp161948specifying an engine (by it's unique B<id> string) will cause B<s_client> 192*2175Sjp161948to attempt to obtain a functional reference to the specified engine, 193*2175Sjp161948thus initialising it if needed. The engine will then be set as the default 194*2175Sjp161948for all available algorithms. 195*2175Sjp161948 196*2175Sjp161948=item B<-rand file(s)> 197*2175Sjp161948 198*2175Sjp161948a file or files containing random data used to seed the random number 199*2175Sjp161948generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 200*2175Sjp161948Multiple files can be specified separated by a OS-dependent character. 201*2175Sjp161948The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 202*2175Sjp161948all others. 203*2175Sjp161948 204*2175Sjp161948=back 205*2175Sjp161948 206*2175Sjp161948=head1 CONNECTED COMMANDS 207*2175Sjp161948 208*2175Sjp161948If a connection is established with an SSL server then any data received 209*2175Sjp161948from the server is displayed and any key presses will be sent to the 210*2175Sjp161948server. When used interactively (which means neither B<-quiet> nor B<-ign_eof> 211*2175Sjp161948have been given), the session will be renegotiated if the line begins with an 212*2175Sjp161948B<R>, and if the line begins with a B<Q> or if end of file is reached, the 213*2175Sjp161948connection will be closed down. 214*2175Sjp161948 215*2175Sjp161948=head1 NOTES 216*2175Sjp161948 217*2175Sjp161948B<s_client> can be used to debug SSL servers. To connect to an SSL HTTP 218*2175Sjp161948server the command: 219*2175Sjp161948 220*2175Sjp161948 openssl s_client -connect servername:443 221*2175Sjp161948 222*2175Sjp161948would typically be used (https uses port 443). If the connection succeeds 223*2175Sjp161948then an HTTP command can be given such as "GET /" to retrieve a web page. 224*2175Sjp161948 225*2175Sjp161948If the handshake fails then there are several possible causes, if it is 226*2175Sjp161948nothing obvious like no client certificate then the B<-bugs>, B<-ssl2>, 227*2175Sjp161948B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> options can be tried 228*2175Sjp161948in case it is a buggy server. In particular you should play with these 229*2175Sjp161948options B<before> submitting a bug report to an OpenSSL mailing list. 230*2175Sjp161948 231*2175Sjp161948A frequent problem when attempting to get client certificates working 232*2175Sjp161948is that a web client complains it has no certificates or gives an empty 233*2175Sjp161948list to choose from. This is normally because the server is not sending 234*2175Sjp161948the clients certificate authority in its "acceptable CA list" when it 235*2175Sjp161948requests a certificate. By using B<s_client> the CA list can be viewed 236*2175Sjp161948and checked. However some servers only request client authentication 237*2175Sjp161948after a specific URL is requested. To obtain the list in this case it 238*2175Sjp161948is necessary to use the B<-prexit> option and send an HTTP request 239*2175Sjp161948for an appropriate page. 240*2175Sjp161948 241*2175Sjp161948If a certificate is specified on the command line using the B<-cert> 242*2175Sjp161948option it will not be used unless the server specifically requests 243*2175Sjp161948a client certificate. Therefor merely including a client certificate 244*2175Sjp161948on the command line is no guarantee that the certificate works. 245*2175Sjp161948 246*2175Sjp161948If there are problems verifying a server certificate then the 247*2175Sjp161948B<-showcerts> option can be used to show the whole chain. 248*2175Sjp161948 249*2175Sjp161948=head1 BUGS 250*2175Sjp161948 251*2175Sjp161948Because this program has a lot of options and also because some of 252*2175Sjp161948the techniques used are rather old, the C source of s_client is rather 253*2175Sjp161948hard to read and not a model of how things should be done. A typical 254*2175Sjp161948SSL client program would be much simpler. 255*2175Sjp161948 256*2175Sjp161948The B<-verify> option should really exit if the server verification 257*2175Sjp161948fails. 258*2175Sjp161948 259*2175Sjp161948The B<-prexit> option is a bit of a hack. We should really report 260*2175Sjp161948information whenever a session is renegotiated. 261*2175Sjp161948 262*2175Sjp161948=head1 SEE ALSO 263*2175Sjp161948 264*2175Sjp161948L<sess_id(1)|sess_id(1)>, L<s_server(1)|s_server(1)>, L<ciphers(1)|ciphers(1)> 265*2175Sjp161948 266*2175Sjp161948=cut 267