1*2175Sjp161948 2*2175Sjp161948=pod 3*2175Sjp161948 4*2175Sjp161948=head1 NAME 5*2175Sjp161948 6*2175Sjp161948s_server - SSL/TLS server program 7*2175Sjp161948 8*2175Sjp161948=head1 SYNOPSIS 9*2175Sjp161948 10*2175Sjp161948B<openssl> B<s_server> 11*2175Sjp161948[B<-accept port>] 12*2175Sjp161948[B<-context id>] 13*2175Sjp161948[B<-verify depth>] 14*2175Sjp161948[B<-Verify depth>] 15*2175Sjp161948[B<-cert filename>] 16*2175Sjp161948[B<-certform DER|PEM>] 17*2175Sjp161948[B<-key keyfile>] 18*2175Sjp161948[B<-keyform DER|PEM>] 19*2175Sjp161948[B<-pass arg>] 20*2175Sjp161948[B<-dcert filename>] 21*2175Sjp161948[B<-dcertform DER|PEM>] 22*2175Sjp161948[B<-dkey keyfile>] 23*2175Sjp161948[B<-dkeyform DER|PEM>] 24*2175Sjp161948[B<-dpass arg>] 25*2175Sjp161948[B<-dhparam filename>] 26*2175Sjp161948[B<-nbio>] 27*2175Sjp161948[B<-nbio_test>] 28*2175Sjp161948[B<-crlf>] 29*2175Sjp161948[B<-debug>] 30*2175Sjp161948[B<-msg>] 31*2175Sjp161948[B<-state>] 32*2175Sjp161948[B<-CApath directory>] 33*2175Sjp161948[B<-CAfile filename>] 34*2175Sjp161948[B<-nocert>] 35*2175Sjp161948[B<-cipher cipherlist>] 36*2175Sjp161948[B<-quiet>] 37*2175Sjp161948[B<-no_tmp_rsa>] 38*2175Sjp161948[B<-ssl2>] 39*2175Sjp161948[B<-ssl3>] 40*2175Sjp161948[B<-tls1>] 41*2175Sjp161948[B<-no_ssl2>] 42*2175Sjp161948[B<-no_ssl3>] 43*2175Sjp161948[B<-no_tls1>] 44*2175Sjp161948[B<-no_dhe>] 45*2175Sjp161948[B<-bugs>] 46*2175Sjp161948[B<-hack>] 47*2175Sjp161948[B<-www>] 48*2175Sjp161948[B<-WWW>] 49*2175Sjp161948[B<-HTTP>] 50*2175Sjp161948[B<-engine id>] 51*2175Sjp161948[B<-id_prefix arg>] 52*2175Sjp161948[B<-rand file(s)>] 53*2175Sjp161948 54*2175Sjp161948=head1 DESCRIPTION 55*2175Sjp161948 56*2175Sjp161948The B<s_server> command implements a generic SSL/TLS server which listens 57*2175Sjp161948for connections on a given port using SSL/TLS. 58*2175Sjp161948 59*2175Sjp161948=head1 OPTIONS 60*2175Sjp161948 61*2175Sjp161948=over 4 62*2175Sjp161948 63*2175Sjp161948=item B<-accept port> 64*2175Sjp161948 65*2175Sjp161948the TCP port to listen on for connections. If not specified 4433 is used. 66*2175Sjp161948 67*2175Sjp161948=item B<-context id> 68*2175Sjp161948 69*2175Sjp161948sets the SSL context id. It can be given any string value. If this option 70*2175Sjp161948is not present a default value will be used. 71*2175Sjp161948 72*2175Sjp161948=item B<-cert certname> 73*2175Sjp161948 74*2175Sjp161948The certificate to use, most servers cipher suites require the use of a 75*2175Sjp161948certificate and some require a certificate with a certain public key type: 76*2175Sjp161948for example the DSS cipher suites require a certificate containing a DSS 77*2175Sjp161948(DSA) key. If not specified then the filename "server.pem" will be used. 78*2175Sjp161948 79*2175Sjp161948=item B<-certform format> 80*2175Sjp161948 81*2175Sjp161948The certificate format to use: DER or PEM. PEM is the default. 82*2175Sjp161948 83*2175Sjp161948=item B<-key keyfile> 84*2175Sjp161948 85*2175Sjp161948The private key to use. If not specified then the certificate file will 86*2175Sjp161948be used. 87*2175Sjp161948 88*2175Sjp161948=item B<-keyform format> 89*2175Sjp161948 90*2175Sjp161948The private format to use: DER or PEM. PEM is the default. 91*2175Sjp161948 92*2175Sjp161948=item B<-pass arg> 93*2175Sjp161948 94*2175Sjp161948the private key password source. For more information about the format of B<arg> 95*2175Sjp161948see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 96*2175Sjp161948 97*2175Sjp161948=item B<-dcert filename>, B<-dkey keyname> 98*2175Sjp161948 99*2175Sjp161948specify an additional certificate and private key, these behave in the 100*2175Sjp161948same manner as the B<-cert> and B<-key> options except there is no default 101*2175Sjp161948if they are not specified (no additional certificate and key is used). As 102*2175Sjp161948noted above some cipher suites require a certificate containing a key of 103*2175Sjp161948a certain type. Some cipher suites need a certificate carrying an RSA key 104*2175Sjp161948and some a DSS (DSA) key. By using RSA and DSS certificates and keys 105*2175Sjp161948a server can support clients which only support RSA or DSS cipher suites 106*2175Sjp161948by using an appropriate certificate. 107*2175Sjp161948 108*2175Sjp161948=item B<-dcertform format>, B<-dkeyform format>, B<-dpass arg> 109*2175Sjp161948 110*2175Sjp161948addtional certificate and private key format and passphrase respectively. 111*2175Sjp161948 112*2175Sjp161948=item B<-nocert> 113*2175Sjp161948 114*2175Sjp161948if this option is set then no certificate is used. This restricts the 115*2175Sjp161948cipher suites available to the anonymous ones (currently just anonymous 116*2175Sjp161948DH). 117*2175Sjp161948 118*2175Sjp161948=item B<-dhparam filename> 119*2175Sjp161948 120*2175Sjp161948the DH parameter file to use. The ephemeral DH cipher suites generate keys 121*2175Sjp161948using a set of DH parameters. If not specified then an attempt is made to 122*2175Sjp161948load the parameters from the server certificate file. If this fails then 123*2175Sjp161948a static set of parameters hard coded into the s_server program will be used. 124*2175Sjp161948 125*2175Sjp161948=item B<-no_dhe> 126*2175Sjp161948 127*2175Sjp161948if this option is set then no DH parameters will be loaded effectively 128*2175Sjp161948disabling the ephemeral DH cipher suites. 129*2175Sjp161948 130*2175Sjp161948=item B<-no_tmp_rsa> 131*2175Sjp161948 132*2175Sjp161948certain export cipher suites sometimes use a temporary RSA key, this option 133*2175Sjp161948disables temporary RSA key generation. 134*2175Sjp161948 135*2175Sjp161948=item B<-verify depth>, B<-Verify depth> 136*2175Sjp161948 137*2175Sjp161948The verify depth to use. This specifies the maximum length of the 138*2175Sjp161948client certificate chain and makes the server request a certificate from 139*2175Sjp161948the client. With the B<-verify> option a certificate is requested but the 140*2175Sjp161948client does not have to send one, with the B<-Verify> option the client 141*2175Sjp161948must supply a certificate or an error occurs. 142*2175Sjp161948 143*2175Sjp161948=item B<-CApath directory> 144*2175Sjp161948 145*2175Sjp161948The directory to use for client certificate verification. This directory 146*2175Sjp161948must be in "hash format", see B<verify> for more information. These are 147*2175Sjp161948also used when building the server certificate chain. 148*2175Sjp161948 149*2175Sjp161948=item B<-CAfile file> 150*2175Sjp161948 151*2175Sjp161948A file containing trusted certificates to use during client authentication 152*2175Sjp161948and to use when attempting to build the server certificate chain. The list 153*2175Sjp161948is also used in the list of acceptable client CAs passed to the client when 154*2175Sjp161948a certificate is requested. 155*2175Sjp161948 156*2175Sjp161948=item B<-state> 157*2175Sjp161948 158*2175Sjp161948prints out the SSL session states. 159*2175Sjp161948 160*2175Sjp161948=item B<-debug> 161*2175Sjp161948 162*2175Sjp161948print extensive debugging information including a hex dump of all traffic. 163*2175Sjp161948 164*2175Sjp161948=item B<-msg> 165*2175Sjp161948 166*2175Sjp161948show all protocol messages with hex dump. 167*2175Sjp161948 168*2175Sjp161948=item B<-nbio_test> 169*2175Sjp161948 170*2175Sjp161948tests non blocking I/O 171*2175Sjp161948 172*2175Sjp161948=item B<-nbio> 173*2175Sjp161948 174*2175Sjp161948turns on non blocking I/O 175*2175Sjp161948 176*2175Sjp161948=item B<-crlf> 177*2175Sjp161948 178*2175Sjp161948this option translated a line feed from the terminal into CR+LF. 179*2175Sjp161948 180*2175Sjp161948=item B<-quiet> 181*2175Sjp161948 182*2175Sjp161948inhibit printing of session and certificate information. 183*2175Sjp161948 184*2175Sjp161948=item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1> 185*2175Sjp161948 186*2175Sjp161948these options disable the use of certain SSL or TLS protocols. By default 187*2175Sjp161948the initial handshake uses a method which should be compatible with all 188*2175Sjp161948servers and permit them to use SSL v3, SSL v2 or TLS as appropriate. 189*2175Sjp161948 190*2175Sjp161948=item B<-bugs> 191*2175Sjp161948 192*2175Sjp161948there are several known bug in SSL and TLS implementations. Adding this 193*2175Sjp161948option enables various workarounds. 194*2175Sjp161948 195*2175Sjp161948=item B<-hack> 196*2175Sjp161948 197*2175Sjp161948this option enables a further workaround for some some early Netscape 198*2175Sjp161948SSL code (?). 199*2175Sjp161948 200*2175Sjp161948=item B<-cipher cipherlist> 201*2175Sjp161948 202*2175Sjp161948this allows the cipher list used by the server to be modified. When 203*2175Sjp161948the client sends a list of supported ciphers the first client cipher 204*2175Sjp161948also included in the server list is used. Because the client specifies 205*2175Sjp161948the preference order, the order of the server cipherlist irrelevant. See 206*2175Sjp161948the B<ciphers> command for more information. 207*2175Sjp161948 208*2175Sjp161948=item B<-www> 209*2175Sjp161948 210*2175Sjp161948sends a status message back to the client when it connects. This includes 211*2175Sjp161948lots of information about the ciphers used and various session parameters. 212*2175Sjp161948The output is in HTML format so this option will normally be used with a 213*2175Sjp161948web browser. 214*2175Sjp161948 215*2175Sjp161948=item B<-WWW> 216*2175Sjp161948 217*2175Sjp161948emulates a simple web server. Pages will be resolved relative to the 218*2175Sjp161948current directory, for example if the URL https://myhost/page.html is 219*2175Sjp161948requested the file ./page.html will be loaded. 220*2175Sjp161948 221*2175Sjp161948=item B<-HTTP> 222*2175Sjp161948 223*2175Sjp161948emulates a simple web server. Pages will be resolved relative to the 224*2175Sjp161948current directory, for example if the URL https://myhost/page.html is 225*2175Sjp161948requested the file ./page.html will be loaded. The files loaded are 226*2175Sjp161948assumed to contain a complete and correct HTTP response (lines that 227*2175Sjp161948are part of the HTTP response line and headers must end with CRLF). 228*2175Sjp161948 229*2175Sjp161948=item B<-engine id> 230*2175Sjp161948 231*2175Sjp161948specifying an engine (by it's unique B<id> string) will cause B<s_server> 232*2175Sjp161948to attempt to obtain a functional reference to the specified engine, 233*2175Sjp161948thus initialising it if needed. The engine will then be set as the default 234*2175Sjp161948for all available algorithms. 235*2175Sjp161948 236*2175Sjp161948=item B<-id_prefix arg> 237*2175Sjp161948 238*2175Sjp161948generate SSL/TLS session IDs prefixed by B<arg>. This is mostly useful 239*2175Sjp161948for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple 240*2175Sjp161948servers, when each of which might be generating a unique range of session 241*2175Sjp161948IDs (eg. with a certain prefix). 242*2175Sjp161948 243*2175Sjp161948=item B<-rand file(s)> 244*2175Sjp161948 245*2175Sjp161948a file or files containing random data used to seed the random number 246*2175Sjp161948generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 247*2175Sjp161948Multiple files can be specified separated by a OS-dependent character. 248*2175Sjp161948The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 249*2175Sjp161948all others. 250*2175Sjp161948 251*2175Sjp161948=back 252*2175Sjp161948 253*2175Sjp161948=head1 CONNECTED COMMANDS 254*2175Sjp161948 255*2175Sjp161948If a connection request is established with an SSL client and neither the 256*2175Sjp161948B<-www> nor the B<-WWW> option has been used then normally any data received 257*2175Sjp161948from the client is displayed and any key presses will be sent to the client. 258*2175Sjp161948 259*2175Sjp161948Certain single letter commands are also recognized which perform special 260*2175Sjp161948operations: these are listed below. 261*2175Sjp161948 262*2175Sjp161948=over 4 263*2175Sjp161948 264*2175Sjp161948=item B<q> 265*2175Sjp161948 266*2175Sjp161948end the current SSL connection but still accept new connections. 267*2175Sjp161948 268*2175Sjp161948=item B<Q> 269*2175Sjp161948 270*2175Sjp161948end the current SSL connection and exit. 271*2175Sjp161948 272*2175Sjp161948=item B<r> 273*2175Sjp161948 274*2175Sjp161948renegotiate the SSL session. 275*2175Sjp161948 276*2175Sjp161948=item B<R> 277*2175Sjp161948 278*2175Sjp161948renegotiate the SSL session and request a client certificate. 279*2175Sjp161948 280*2175Sjp161948=item B<P> 281*2175Sjp161948 282*2175Sjp161948send some plain text down the underlying TCP connection: this should 283*2175Sjp161948cause the client to disconnect due to a protocol violation. 284*2175Sjp161948 285*2175Sjp161948=item B<S> 286*2175Sjp161948 287*2175Sjp161948print out some session cache status information. 288*2175Sjp161948 289*2175Sjp161948=back 290*2175Sjp161948 291*2175Sjp161948=head1 NOTES 292*2175Sjp161948 293*2175Sjp161948B<s_server> can be used to debug SSL clients. To accept connections from 294*2175Sjp161948a web browser the command: 295*2175Sjp161948 296*2175Sjp161948 openssl s_server -accept 443 -www 297*2175Sjp161948 298*2175Sjp161948can be used for example. 299*2175Sjp161948 300*2175Sjp161948Most web browsers (in particular Netscape and MSIE) only support RSA cipher 301*2175Sjp161948suites, so they cannot connect to servers which don't use a certificate 302*2175Sjp161948carrying an RSA key or a version of OpenSSL with RSA disabled. 303*2175Sjp161948 304*2175Sjp161948Although specifying an empty list of CAs when requesting a client certificate 305*2175Sjp161948is strictly speaking a protocol violation, some SSL clients interpret this to 306*2175Sjp161948mean any CA is acceptable. This is useful for debugging purposes. 307*2175Sjp161948 308*2175Sjp161948The session parameters can printed out using the B<sess_id> program. 309*2175Sjp161948 310*2175Sjp161948=head1 BUGS 311*2175Sjp161948 312*2175Sjp161948Because this program has a lot of options and also because some of 313*2175Sjp161948the techniques used are rather old, the C source of s_server is rather 314*2175Sjp161948hard to read and not a model of how things should be done. A typical 315*2175Sjp161948SSL server program would be much simpler. 316*2175Sjp161948 317*2175Sjp161948The output of common ciphers is wrong: it just gives the list of ciphers that 318*2175Sjp161948OpenSSL recognizes and the client supports. 319*2175Sjp161948 320*2175Sjp161948There should be a way for the B<s_server> program to print out details of any 321*2175Sjp161948unknown cipher suites a client says it supports. 322*2175Sjp161948 323*2175Sjp161948=head1 SEE ALSO 324*2175Sjp161948 325*2175Sjp161948L<sess_id(1)|sess_id(1)>, L<s_client(1)|s_client(1)>, L<ciphers(1)|ciphers(1)> 326*2175Sjp161948 327*2175Sjp161948=cut 328