summaryrefslogtreecommitdiff
path: root/doc/invoke-gnutls-serv.texi
blob: 3789bc3c6cd158eca8425afb3f864c23c54a4a9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
@node gnutls-serv Invocation
@section Invoking gnutls-serv
@pindex gnutls-serv
@ignore
#  -*- buffer-read-only: t -*- vi: set ro:
# 
# DO NOT EDIT THIS FILE   (invoke-gnutls-serv.texi)
# 
# It has been AutoGen-ed  May  9, 2013 at 01:39:23 PM by AutoGen 5.16
# From the definitions    ../src/serv-args.def
# and the template file   agtexi-cmd.tpl
@end ignore


Server program that listens to incoming TLS connections.

This section was generated by @strong{AutoGen},
using the @code{agtexi-cmd} template and the option descriptions for the @code{gnutls-serv} program.
This software is released under the GNU General Public License, version 3 or later.


@anchor{gnutls-serv usage}
@subheading gnutls-serv help/usage (-h)
@cindex gnutls-serv help

This is the automatically generated usage text for gnutls-serv.
The text printed is the same whether for the @code{help} option (-h) or the @code{more-help} option (-!).  @code{more-help} will print
the usage text by passing it through a pager program.
@code{more-help} is disabled on platforms without a working
@code{fork(2)} function.  The @code{PAGER} environment variable is
used to select the program, defaulting to @file{more}.  Both will exit
with a status code of 0.

@exampleindent 0
@example
gnutls-serv - GnuTLS server - Ver. @@VERSION@@
USAGE:  gnutls-serv [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...

   -d, --debug=num            Enable debugging.
                                - It must be in the range:
                                  0 to 9999
       --noticket             Don't accept session tickets
   -g, --generate             Generate Diffie-Hellman and RSA-export parameters
   -q, --quiet                Suppress some messages
       --nodb                 Do not use a resumption database
       --http                 Act as an HTTP server
       --echo                 Act as an Echo server
   -u, --udp                  Use DTLS (datagram TLS) over UDP
       --mtu=num              Set MTU for datagram TLS
                                - It must be in the range:
                                  0 to 17000
       --srtp-profiles=str    Offer SRTP profiles
   -a, --disable-client-cert  Do not request a client certificate
   -r, --require-client-cert  Require a client certificate
   -b, --heartbeat            Activate heartbeat support
       --x509fmtder           Use DER format for certificates to read from
       --priority=str         Priorities string
       --dhparams=file        DH params file to use
                                - file must pre-exist
       --x509cafile=str       Certificate file or PKCS #11 URL to use
       --x509crlfile=file     CRL file to use
                                - file must pre-exist
       --pgpkeyfile=file      PGP Key file to use
                                - file must pre-exist
       --pgpkeyring=file      PGP Key ring file to use
                                - file must pre-exist
       --pgpcertfile=file     PGP Public Key (certificate) file to use
                                - file must pre-exist
       --x509keyfile=str      X.509 key file or PKCS #11 URL to use
       --x509certfile=str     X.509 Certificate file or PKCS #11 URL to use
       --x509dsakeyfile=str   Alternative X.509 key file or PKCS #11 URL to use
       --x509dsacertfile=str  Alternative X.509 Certificate file or PKCS #11 URL to use
       --x509ecckeyfile=str   Alternative X.509 key file or PKCS #11 URL to use
       --x509ecccertfile=str  Alternative X.509 Certificate file or PKCS #11 URL to use
       --pgpsubkey=str        PGP subkey to use (hex or auto)
       --srppasswd=file       SRP password file to use
                                - file must pre-exist
       --srppasswdconf=file   SRP password configuration file to use
                                - file must pre-exist
       --pskpasswd=file       PSK password file to use
                                - file must pre-exist
       --pskhint=str          PSK identity hint to use
       --ocsp-response=file   The OCSP response to send to client
                                - file must pre-exist
   -p, --port=num             The port to connect to
   -l, --list                 Print a list of the supported algorithms and modes
   -v, --version[=arg]        Output version information and exit
   -h, --help                 Display extended usage information and exit
   -!, --more-help            Extended usage information passed thru pager

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.



Server program that listens to incoming TLS connections.

please send bug reports to:  bug-gnutls@@gnu.org
@end example
@exampleindent 4

@anchor{gnutls-serv debug}
@subheading debug option (-d)

This is the ``enable debugging.'' option.
This option takes an argument number.
Specifies the debug level.
@anchor{gnutls-serv heartbeat}
@subheading heartbeat option (-b)

This is the ``activate heartbeat support'' option.
Regularly ping client via heartbeat extension messages
@anchor{gnutls-serv priority}
@subheading priority option

This is the ``priorities string'' option.
This option takes an argument string.
TLS algorithms and protocols to enable. You can
use predefined sets of ciphersuites such as PERFORMANCE,
NORMAL, SECURE128, SECURE256.

Check  the  GnuTLS  manual  on  section  ``Priority strings'' for more
information on allowed keywords
@anchor{gnutls-serv ocsp-response}
@subheading ocsp-response option

This is the ``the ocsp response to send to client'' option.
This option takes an argument file.
If the client requested an OCSP response, return data from this file to the client.
@anchor{gnutls-serv list}
@subheading list option (-l)

This is the ``print a list of the supported algorithms and modes'' option.
Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
@anchor{gnutls-serv exit status}
@subheading gnutls-serv exit status

One of the following exit values will be returned:
@table @samp
@item 0 (EXIT_SUCCESS)
Successful program execution.
@item 1 (EXIT_FAILURE)
The operation failed or the command syntax was not valid.
@end table
@anchor{gnutls-serv See Also}
@subheading gnutls-serv See Also
gnutls-cli-debug(1), gnutls-cli(1)

@anchor{gnutls-serv Examples}
@subheading gnutls-serv Examples
Running your own TLS server based on GnuTLS can be useful when
debugging clients and/or GnuTLS itself.  This section describes how to
use @code{gnutls-serv} as a simple HTTPS server.

The most basic server can be started as:

@example
gnutls-serv --http
@end example

It will only support anonymous ciphersuites, which many TLS clients
refuse to use.

The next step is to add support for X.509.  First we generate a CA:

@example
$ certtool --generate-privkey > x509-ca-key.pem
$ echo 'cn = GnuTLS test CA' > ca.tmpl
$ echo 'ca' >> ca.tmpl
$ echo 'cert_signing_key' >> ca.tmpl
$ certtool --generate-self-signed --load-privkey x509-ca-key.pem \
  --template ca.tmpl --outfile x509-ca.pem
...
@end example

Then generate a server certificate.  Remember to change the dns_name
value to the name of your server host, or skip that command to avoid
the field.

@example
$ certtool --generate-privkey > x509-server-key.pem
$ echo 'organization = GnuTLS test server' > server.tmpl
$ echo 'cn = test.gnutls.org' >> server.tmpl
$ echo 'tls_www_server' >> server.tmpl
$ echo 'encryption_key' >> server.tmpl
$ echo 'signing_key' >> server.tmpl
$ echo 'dns_name = test.gnutls.org' >> server.tmpl
$ certtool --generate-certificate --load-privkey x509-server-key.pem \
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
  --template server.tmpl --outfile x509-server.pem
...
@end example

For use in the client, you may want to generate a client certificate
as well.

@example
$ certtool --generate-privkey > x509-client-key.pem
$ echo 'cn = GnuTLS test client' > client.tmpl
$ echo 'tls_www_client' >> client.tmpl
$ echo 'encryption_key' >> client.tmpl
$ echo 'signing_key' >> client.tmpl
$ certtool --generate-certificate --load-privkey x509-client-key.pem \
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
  --template client.tmpl --outfile x509-client.pem
...
@end example

To be able to import the client key/certificate into some
applications, you will need to convert them into a PKCS#12 structure.
This also encrypts the security sensitive key with a password.

@example
$ certtool --to-p12 --load-ca-certificate x509-ca.pem \
  --load-privkey x509-client-key.pem --load-certificate x509-client.pem \
  --outder --outfile x509-client.p12
@end example

For icing, we'll create a proxy certificate for the client too.

@example
$ certtool --generate-privkey > x509-proxy-key.pem
$ echo 'cn = GnuTLS test client proxy' > proxy.tmpl
$ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
  --load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
  --load-certificate x509-client.pem --template proxy.tmpl \
  --outfile x509-proxy.pem
...
@end example

Then start the server again:

@example
$ gnutls-serv --http \
            --x509cafile x509-ca.pem \
            --x509keyfile x509-server-key.pem \
            --x509certfile x509-server.pem
@end example

Try connecting to the server using your web browser.  Note that the
server listens to port 5556 by default.

While you are at it, to allow connections using DSA, you can also
create a DSA key and certificate for the server.  These credentials
will be used in the final example below.

@example
$ certtool --generate-privkey --dsa > x509-server-key-dsa.pem
$ certtool --generate-certificate --load-privkey x509-server-key-dsa.pem \
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
  --template server.tmpl --outfile x509-server-dsa.pem
...
@end example

The next step is to create OpenPGP credentials for the server.

@example
gpg --gen-key
...enter whatever details you want, use 'test.gnutls.org' as name...
@end example

Make a note of the OpenPGP key identifier of the newly generated key,
here it was @code{5D1D14D8}.  You will need to export the key for
GnuTLS to be able to use it.

@example
gpg -a --export 5D1D14D8 > openpgp-server.txt
gpg --export 5D1D14D8 > openpgp-server.bin
gpg --export-secret-keys 5D1D14D8 > openpgp-server-key.bin
gpg -a --export-secret-keys 5D1D14D8 > openpgp-server-key.txt
@end example

Let's start the server with support for OpenPGP credentials:

@example
gnutls-serv --http \
            --pgpkeyfile openpgp-server-key.txt \
            --pgpcertfile openpgp-server.txt
@end example

The next step is to add support for SRP authentication. This requires
an SRP password file created with @code{srptool}.
To start the server with SRP support:

@example
gnutls-serv --http \
            --srppasswdconf srp-tpasswd.conf \
            --srppasswd srp-passwd.txt
@end example

Let's also start a server with support for PSK. This would require
a password file created with @code{psktool}.

@example
gnutls-serv --http \
            --pskpasswd psk-passwd.txt
@end example

Finally, we start the server with all the earlier parameters and you
get this command:

@example
gnutls-serv --http \
            --x509cafile x509-ca.pem \
            --x509keyfile x509-server-key.pem \
            --x509certfile x509-server.pem \
            --x509dsakeyfile x509-server-key-dsa.pem \
            --x509dsacertfile x509-server-dsa.pem \
            --pgpkeyfile openpgp-server-key.txt \
            --pgpcertfile openpgp-server.txt \
            --srppasswdconf srp-tpasswd.conf \
            --srppasswd srp-passwd.txt \
            --pskpasswd psk-passwd.txt
@end example