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