1 AutoGen Definitions options
;
2 prog
-name
= gnutls
-serv
;
3 prog
-title
= "GnuTLS server";
4 prog
-desc
= "Simple server program to act as an HTTPS or TLS echo service.";
5 short
-usage
= "Usage: gnutls-serv [options]\ngnutls-serv --help for usage instructions.\n";
7 detail
= "Server program that listens to incoming TLS connections.";
13 descrip
= "Don't accept session tickets";
20 descrip
= "Generate Diffie-Hellman and RSA-export parameters";
27 descrip
= "Suppress some messages";
33 descrip
= "Do not use a resumption database";
39 descrip
= "Act as an HTTP server";
45 descrip
= "Act as an Echo server";
52 descrip
= "Use DTLS (datagram TLS) over UDP";
59 arg
-range
= "0->17000";
60 descrip
= "Set MTU for datagram TLS";
65 name
= disable
-client
-cert
;
67 descrip
= "Do not request a client certificate";
72 name
= require
-client
-cert
;
74 descrip
= "Require a client certificate";
81 descrip
= "Activate heartbeat support";
82 doc
= "Regularly ping client via heartbeat extension messages";
87 descrip
= "Use DER format for certificates to read from";
94 descrip
= "Priorities string";
95 doc
= "TLS algorithms and protocols to enable. You can
96 use predefined sets of ciphersuites such as PERFORMANCE,
97 NORMAL, SECURE128, SECURE256.
99 Check the GnuTLS manual on section ``Priority strings'' for more
100 information on allowed keywords";
107 descrip
= "DH params file to use";
114 descrip
= "Certificate file or PKCS #11 URL to use";
122 descrip
= "CRL file to use";
130 descrip
= "PGP Key file to use";
138 descrip
= "PGP Key ring file to use";
146 descrip
= "PGP Public Key (certificate) file to use";
153 descrip
= "X.509 key file or PKCS #11 URL to use";
160 descrip
= "X.509 Certificate file or PKCS #11 URL to use";
165 name
= x509dsakeyfile
;
167 descrip
= "Alternative X.509 key file or PKCS #11 URL to use";
172 name
= x509dsacertfile
;
174 descrip
= "Alternative X.509 Certificate file or PKCS #11 URL to use";
179 name
= x509ecckeyfile
;
181 descrip
= "Alternative X.509 key file or PKCS #11 URL to use";
186 name
= x509ecccertfile
;
188 descrip
= "Alternative X.509 Certificate file or PKCS #11 URL to use";
195 descrip
= "PGP subkey to use (hex or auto)";
203 descrip
= "SRP password file to use";
208 name
= srppasswdconf
;
211 descrip
= "SRP password configuration file to use";
219 descrip
= "PSK password file to use";
226 descrip
= "PSK identity hint to use";
234 descrip
= "The port to connect to";
241 descrip
= "Print a list of the supported algorithms and modes";
242 doc
= "Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.";
246 ds
-type
= 'SEE ALSO'; // or anything else
247 ds
-format
= 'texi'; // or texi or mdoc format
248 ds
-text
= <<-_EOText_
249 gnutls
-cli
-debug(1), gnutls
-cli(1)
254 ds
-type
= 'EXAMPLES';
257 Running your own TLS server based on GnuTLS can be useful when
258 debugging clients and
/or GnuTLS itself. This section describes how to
259 use @code
{gnutls
-serv
} as a simple HTTPS server.
261 The most basic server can be started as
:
267 It will only support anonymous ciphersuites
, which many TLS clients
270 The next step is to add support for X
.509. First we generate a CA
:
273 $ certtool
--generate
-privkey
> x509
-ca
-key.pem
274 $ echo
'cn = GnuTLS test CA' > ca.tmpl
275 $ echo
'ca' >> ca.tmpl
276 $ echo
'cert_signing_key' >> ca.tmpl
277 $ certtool
--generate
-self
-signed
--load
-privkey x509
-ca
-key.pem \
278 --template ca.tmpl
--outfile x509
-ca.pem
282 Then generate a server certificate. Remember to change the dns_name
283 value to the name of your server host
, or skip that command to avoid
287 $ certtool
--generate
-privkey
> x509
-server
-key.pem
288 $ echo
'organization = GnuTLS test server' > server.tmpl
289 $ echo
'cn = test.gnutls.org' >> server.tmpl
290 $ echo
'tls_www_server' >> server.tmpl
291 $ echo
'encryption_key' >> server.tmpl
292 $ echo
'signing_key' >> server.tmpl
293 $ echo
'dns_name = test.gnutls.org' >> server.tmpl
294 $ certtool
--generate
-certificate
--load
-privkey x509
-server
-key.pem \
295 --load
-ca
-certificate x509
-ca.pem
--load
-ca
-privkey x509
-ca
-key.pem \
296 --template server.tmpl
--outfile x509
-server.pem
300 For use in the client
, you may want to generate a client certificate
304 $ certtool
--generate
-privkey
> x509
-client
-key.pem
305 $ echo
'cn = GnuTLS test client' > client.tmpl
306 $ echo
'tls_www_client' >> client.tmpl
307 $ echo
'encryption_key' >> client.tmpl
308 $ echo
'signing_key' >> client.tmpl
309 $ certtool
--generate
-certificate
--load
-privkey x509
-client
-key.pem \
310 --load
-ca
-certificate x509
-ca.pem
--load
-ca
-privkey x509
-ca
-key.pem \
311 --template client.tmpl
--outfile x509
-client.pem
315 To be able to import the client key
/certificate into some
316 applications
, you will need to convert them into a PKCS#
12 structure.
317 This also encrypts the security sensitive key with a password.
320 $ certtool
--to
-p12
--load
-ca
-certificate x509
-ca.pem \
321 --load
-privkey x509
-client
-key.pem
--load
-certificate x509
-client.pem \
322 --outder
--outfile x509
-client.p12
325 For icing
, we
'll create a proxy certificate for the client too.
328 $ certtool --generate-privkey > x509-proxy-key.pem
329 $ echo 'cn
= GnuTLS test client proxy
' > proxy.tmpl
330 $ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
331 --load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
332 --load-certificate x509-client.pem --template proxy.tmpl \
333 --outfile x509-proxy.pem
337 Then start the server again:
340 $ gnutls-serv --http \
341 --x509cafile x509-ca.pem \
342 --x509keyfile x509-server-key.pem \
343 --x509certfile x509-server.pem
346 Try connecting to the server using your web browser. Note that the
347 server listens to port 5556 by default.
349 While you are at it, to allow connections using DSA, you can also
350 create a DSA key and certificate for the server. These credentials
351 will be used in the final example below.
354 $ certtool --generate-privkey --dsa > x509-server-key-dsa.pem
355 $ certtool --generate-certificate --load-privkey x509-server-key-dsa.pem \
356 --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
357 --template server.tmpl --outfile x509-server-dsa.pem
361 The next step is to create OpenPGP credentials for the server.
365 ...enter whatever details you want, use 'test.gnutls.org
' as name...
368 Make a note of the OpenPGP key identifier of the newly generated key,
369 here it was @code{5D1D14D8}. You will need to export the key for
370 GnuTLS to be able to use it.
373 gpg -a --export 5D1D14D8 > openpgp-server.txt
374 gpg --export 5D1D14D8 > openpgp-server.bin
375 gpg --export-secret-keys 5D1D14D8 > openpgp-server-key.bin
376 gpg -a --export-secret-keys 5D1D14D8 > openpgp-server-key.txt
379 Let's start the server with support for OpenPGP credentials
:
383 --pgpkeyfile openpgp
-server
-key.txt \
384 --pgpcertfile openpgp
-server.txt
387 The next step is to add support for SRP authentication. This requires
388 an SRP password file created with @code
{srptool
}.
389 To start the server with SRP support
:
393 --srppasswdconf srp
-tpasswd.conf \
394 --srppasswd srp
-passwd.txt
397 Let
's also start a server with support for PSK. This would require
398 a password file created with @code{psktool}.
402 --pskpasswd psk-passwd.txt
405 Finally, we start the server with all the earlier parameters and you
410 --x509cafile x509-ca.pem \
411 --x509keyfile x509-server-key.pem \
412 --x509certfile x509-server.pem \
413 --x509dsakeyfile x509-server-key-dsa.pem \
414 --x509dsacertfile x509-server-dsa.pem \
415 --pgpkeyfile openpgp-server-key.txt \
416 --pgpcertfile openpgp-server.txt \
417 --srppasswdconf srp-tpasswd.conf \
418 --srppasswd srp-passwd.txt \
419 --pskpasswd psk-passwd.txt