s_server.pod 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. =pod
  2. =head1 NAME
  3. s_server - SSL/TLS server program
  4. =head1 SYNOPSIS
  5. B<openssl> B<s_server>
  6. [B<-accept port>]
  7. [B<-context id>]
  8. [B<-verify depth>]
  9. [B<-Verify depth>]
  10. [B<-crl_check>]
  11. [B<-crl_check_all>]
  12. [B<-cert filename>]
  13. [B<-certform DER|PEM>]
  14. [B<-key keyfile>]
  15. [B<-keyform DER|PEM>]
  16. [B<-pass arg>]
  17. [B<-dcert filename>]
  18. [B<-dcertform DER|PEM>]
  19. [B<-dkey keyfile>]
  20. [B<-dkeyform DER|PEM>]
  21. [B<-dpass arg>]
  22. [B<-dhparam filename>]
  23. [B<-nbio>]
  24. [B<-nbio_test>]
  25. [B<-crlf>]
  26. [B<-debug>]
  27. [B<-msg>]
  28. [B<-state>]
  29. [B<-CApath directory>]
  30. [B<-CAfile filename>]
  31. [B<-nocert>]
  32. [B<-cipher cipherlist>]
  33. [B<-serverpref>]
  34. [B<-quiet>]
  35. [B<-no_tmp_rsa>]
  36. [B<-ssl2>]
  37. [B<-ssl3>]
  38. [B<-tls1>]
  39. [B<-no_ssl2>]
  40. [B<-no_ssl3>]
  41. [B<-no_tls1>]
  42. [B<-no_dhe>]
  43. [B<-bugs>]
  44. [B<-hack>]
  45. [B<-www>]
  46. [B<-WWW>]
  47. [B<-HTTP>]
  48. [B<-engine id>]
  49. [B<-tlsextdebug>]
  50. [B<-no_ticket>]
  51. [B<-id_prefix arg>]
  52. [B<-rand file(s)>]
  53. =head1 DESCRIPTION
  54. The B<s_server> command implements a generic SSL/TLS server which listens
  55. for connections on a given port using SSL/TLS.
  56. =head1 OPTIONS
  57. =over 4
  58. =item B<-accept port>
  59. the TCP port to listen on for connections. If not specified 4433 is used.
  60. =item B<-context id>
  61. sets the SSL context id. It can be given any string value. If this option
  62. is not present a default value will be used.
  63. =item B<-cert certname>
  64. The certificate to use, most servers cipher suites require the use of a
  65. certificate and some require a certificate with a certain public key type:
  66. for example the DSS cipher suites require a certificate containing a DSS
  67. (DSA) key. If not specified then the filename "server.pem" will be used.
  68. =item B<-certform format>
  69. The certificate format to use: DER or PEM. PEM is the default.
  70. =item B<-key keyfile>
  71. The private key to use. If not specified then the certificate file will
  72. be used.
  73. =item B<-keyform format>
  74. The private format to use: DER or PEM. PEM is the default.
  75. =item B<-pass arg>
  76. the private key password source. For more information about the format of B<arg>
  77. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
  78. =item B<-dcert filename>, B<-dkey keyname>
  79. specify an additional certificate and private key, these behave in the
  80. same manner as the B<-cert> and B<-key> options except there is no default
  81. if they are not specified (no additional certificate and key is used). As
  82. noted above some cipher suites require a certificate containing a key of
  83. a certain type. Some cipher suites need a certificate carrying an RSA key
  84. and some a DSS (DSA) key. By using RSA and DSS certificates and keys
  85. a server can support clients which only support RSA or DSS cipher suites
  86. by using an appropriate certificate.
  87. =item B<-dcertform format>, B<-dkeyform format>, B<-dpass arg>
  88. addtional certificate and private key format and passphrase respectively.
  89. =item B<-nocert>
  90. if this option is set then no certificate is used. This restricts the
  91. cipher suites available to the anonymous ones (currently just anonymous
  92. DH).
  93. =item B<-dhparam filename>
  94. the DH parameter file to use. The ephemeral DH cipher suites generate keys
  95. using a set of DH parameters. If not specified then an attempt is made to
  96. load the parameters from the server certificate file. If this fails then
  97. a static set of parameters hard coded into the s_server program will be used.
  98. =item B<-no_dhe>
  99. if this option is set then no DH parameters will be loaded effectively
  100. disabling the ephemeral DH cipher suites.
  101. =item B<-no_tmp_rsa>
  102. certain export cipher suites sometimes use a temporary RSA key, this option
  103. disables temporary RSA key generation.
  104. =item B<-verify depth>, B<-Verify depth>
  105. The verify depth to use. This specifies the maximum length of the
  106. client certificate chain and makes the server request a certificate from
  107. the client. With the B<-verify> option a certificate is requested but the
  108. client does not have to send one, with the B<-Verify> option the client
  109. must supply a certificate or an error occurs.
  110. If the ciphersuite cannot request a client certificate (for example an
  111. anonymous ciphersuite or PSK) this option has no effect.
  112. =item B<-crl_check>, B<-crl_check_all>
  113. Check the peer certificate has not been revoked by its CA.
  114. The CRL(s) are appended to the certificate file. With the B<-crl_check_all>
  115. option all CRLs of all CAs in the chain are checked.
  116. =item B<-CApath directory>
  117. The directory to use for client certificate verification. This directory
  118. must be in "hash format", see B<verify> for more information. These are
  119. also used when building the server certificate chain.
  120. =item B<-CAfile file>
  121. A file containing trusted certificates to use during client authentication
  122. and to use when attempting to build the server certificate chain. The list
  123. is also used in the list of acceptable client CAs passed to the client when
  124. a certificate is requested.
  125. =item B<-state>
  126. prints out the SSL session states.
  127. =item B<-debug>
  128. print extensive debugging information including a hex dump of all traffic.
  129. =item B<-msg>
  130. show all protocol messages with hex dump.
  131. =item B<-nbio_test>
  132. tests non blocking I/O
  133. =item B<-nbio>
  134. turns on non blocking I/O
  135. =item B<-crlf>
  136. this option translated a line feed from the terminal into CR+LF.
  137. =item B<-quiet>
  138. inhibit printing of session and certificate information.
  139. =item B<-ssl2>, B<-ssl3>, B<-tls1>, B<-no_ssl2>, B<-no_ssl3>, B<-no_tls1>
  140. these options disable the use of certain SSL or TLS protocols. By default
  141. the initial handshake uses a method which should be compatible with all
  142. servers and permit them to use SSL v3, SSL v2 or TLS as appropriate.
  143. =item B<-bugs>
  144. there are several known bug in SSL and TLS implementations. Adding this
  145. option enables various workarounds.
  146. =item B<-hack>
  147. this option enables a further workaround for some some early Netscape
  148. SSL code (?).
  149. =item B<-cipher cipherlist>
  150. this allows the cipher list used by the server to be modified. When
  151. the client sends a list of supported ciphers the first client cipher
  152. also included in the server list is used. Because the client specifies
  153. the preference order, the order of the server cipherlist irrelevant. See
  154. the B<ciphers> command for more information.
  155. =item B<-serverpref>
  156. use the server's cipher preferences, rather than the client's preferences.
  157. =item B<-tlsextdebug>
  158. print out a hex dump of any TLS extensions received from the server.
  159. =item B<-no_ticket>
  160. disable RFC4507bis session ticket support.
  161. =item B<-www>
  162. sends a status message back to the client when it connects. This includes
  163. lots of information about the ciphers used and various session parameters.
  164. The output is in HTML format so this option will normally be used with a
  165. web browser.
  166. =item B<-WWW>
  167. emulates a simple web server. Pages will be resolved relative to the
  168. current directory, for example if the URL https://myhost/page.html is
  169. requested the file ./page.html will be loaded.
  170. =item B<-HTTP>
  171. emulates a simple web server. Pages will be resolved relative to the
  172. current directory, for example if the URL https://myhost/page.html is
  173. requested the file ./page.html will be loaded. The files loaded are
  174. assumed to contain a complete and correct HTTP response (lines that
  175. are part of the HTTP response line and headers must end with CRLF).
  176. =item B<-engine id>
  177. specifying an engine (by it's unique B<id> string) will cause B<s_server>
  178. to attempt to obtain a functional reference to the specified engine,
  179. thus initialising it if needed. The engine will then be set as the default
  180. for all available algorithms.
  181. =item B<-id_prefix arg>
  182. generate SSL/TLS session IDs prefixed by B<arg>. This is mostly useful
  183. for testing any SSL/TLS code (eg. proxies) that wish to deal with multiple
  184. servers, when each of which might be generating a unique range of session
  185. IDs (eg. with a certain prefix).
  186. =item B<-rand file(s)>
  187. a file or files containing random data used to seed the random number
  188. generator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>).
  189. Multiple files can be specified separated by a OS-dependent character.
  190. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  191. all others.
  192. =back
  193. =head1 CONNECTED COMMANDS
  194. If a connection request is established with an SSL client and neither the
  195. B<-www> nor the B<-WWW> option has been used then normally any data received
  196. from the client is displayed and any key presses will be sent to the client.
  197. Certain single letter commands are also recognized which perform special
  198. operations: these are listed below.
  199. =over 4
  200. =item B<q>
  201. end the current SSL connection but still accept new connections.
  202. =item B<Q>
  203. end the current SSL connection and exit.
  204. =item B<r>
  205. renegotiate the SSL session.
  206. =item B<R>
  207. renegotiate the SSL session and request a client certificate.
  208. =item B<P>
  209. send some plain text down the underlying TCP connection: this should
  210. cause the client to disconnect due to a protocol violation.
  211. =item B<S>
  212. print out some session cache status information.
  213. =back
  214. =head1 NOTES
  215. B<s_server> can be used to debug SSL clients. To accept connections from
  216. a web browser the command:
  217. openssl s_server -accept 443 -www
  218. can be used for example.
  219. Most web browsers (in particular Netscape and MSIE) only support RSA cipher
  220. suites, so they cannot connect to servers which don't use a certificate
  221. carrying an RSA key or a version of OpenSSL with RSA disabled.
  222. Although specifying an empty list of CAs when requesting a client certificate
  223. is strictly speaking a protocol violation, some SSL clients interpret this to
  224. mean any CA is acceptable. This is useful for debugging purposes.
  225. The session parameters can printed out using the B<sess_id> program.
  226. TLS extensions are only supported in OpenSSL 0.9.8 if they are explictly
  227. enabled at compile time using for example the B<enable-tlsext> switch.
  228. =head1 BUGS
  229. Because this program has a lot of options and also because some of
  230. the techniques used are rather old, the C source of s_server is rather
  231. hard to read and not a model of how things should be done. A typical
  232. SSL server program would be much simpler.
  233. The output of common ciphers is wrong: it just gives the list of ciphers that
  234. OpenSSL recognizes and the client supports.
  235. There should be a way for the B<s_server> program to print out details of any
  236. unknown cipher suites a client says it supports.
  237. =head1 SEE ALSO
  238. L<sess_id(1)|sess_id(1)>, L<s_client(1)|s_client(1)>, L<ciphers(1)|ciphers(1)>
  239. =cut