s_server.pod 12 KB

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