s_server.pod 12 KB

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