s_server.pod 11 KB

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