s_server.pod 9.9 KB

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