Blame doc/invoke-gnutls-serv.texi

Packit aea12f
@node gnutls-serv Invocation
Packit aea12f
@section Invoking gnutls-serv
Packit aea12f
@pindex gnutls-serv
Packit aea12f
@ignore
Packit aea12f
#  -*- buffer-read-only: t -*- vi: set ro:
Packit aea12f
#
Packit aea12f
# DO NOT EDIT THIS FILE   (invoke-gnutls-serv.texi)
Packit aea12f
#
Packit aea12f
# It has been AutoGen-ed
Packit aea12f
# From the definitions    ../src/serv-args.def
Packit aea12f
# and the template file   agtexi-cmd.tpl
Packit aea12f
@end ignore
Packit aea12f
Packit aea12f
Packit aea12f
Server program that listens to incoming TLS connections.
Packit aea12f
Packit aea12f
This section was generated by @strong{AutoGen},
Packit aea12f
using the @code{agtexi-cmd} template and the option descriptions for the @code{gnutls-serv} program.
Packit aea12f
This software is released under the GNU General Public License, version 3 or later.
Packit aea12f
Packit aea12f
Packit aea12f
@anchor{gnutls-serv usage}
Packit aea12f
@subheading gnutls-serv help/usage (@option{--help})
Packit aea12f
@cindex gnutls-serv help
Packit aea12f
Packit aea12f
This is the automatically generated usage text for gnutls-serv.
Packit aea12f
Packit aea12f
The text printed is the same whether selected with the @code{help} option
Packit aea12f
(@option{--help}) or the @code{more-help} option (@option{--more-help}).  @code{more-help} will print
Packit aea12f
the usage text by passing it through a pager program.
Packit aea12f
@code{more-help} is disabled on platforms without a working
Packit aea12f
@code{fork(2)} function.  The @code{PAGER} environment variable is
Packit aea12f
used to select the program, defaulting to @file{more}.  Both will exit
Packit aea12f
with a status code of 0.
Packit aea12f
Packit aea12f
@exampleindent 0
Packit aea12f
@example
Packit aea12f
gnutls-serv - GnuTLS server
Packit aea12f
Usage:  gnutls-serv [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
Packit aea12f
Packit aea12f
   -d, --debug=num            Enable debugging
Packit aea12f
                                - it must be in the range:
Packit aea12f
                                  0 to 9999
Packit aea12f
       --sni-hostname=str     Server's hostname for server name extension
Packit aea12f
       --sni-hostname-fatal   Send fatal alert on sni-hostname mismatch
Packit aea12f
       --alpn=str             Specify ALPN protocol to be enabled by the server
Packit aea12f
                                - may appear multiple times
Packit aea12f
       --alpn-fatal           Send fatal alert on non-matching ALPN name
Packit aea12f
       --noticket             Don't accept session tickets
Packit aea12f
       --earlydata            Accept early data
Packit aea12f
       --maxearlydata=num     The maximum early data size to accept
Packit aea12f
                                - it must be in the range:
Packit aea12f
                                  1 to 4294967295
Packit aea12f
       --nocookie             Don't require cookie on DTLS sessions
Packit aea12f
   -g, --generate             Generate Diffie-Hellman parameters
Packit aea12f
   -q, --quiet                Suppress some messages
Packit aea12f
       --nodb                 Do not use a resumption database
Packit aea12f
       --http                 Act as an HTTP server
Packit aea12f
       --echo                 Act as an Echo server
Packit aea12f
   -u, --udp                  Use DTLS (datagram TLS) over UDP
Packit aea12f
       --mtu=num              Set MTU for datagram TLS
Packit aea12f
                                - it must be in the range:
Packit aea12f
                                  0 to 17000
Packit aea12f
       --srtp-profiles=str    Offer SRTP profiles
Packit aea12f
   -a, --disable-client-cert  Do not request a client certificate
Packit aea12f
                                - prohibits the option 'require-client-cert'
Packit aea12f
   -r, --require-client-cert  Require a client certificate
Packit aea12f
       --verify-client-cert   If a client certificate is sent then verify it.
Packit aea12f
   -b, --heartbeat            Activate heartbeat support
Packit aea12f
       --x509fmtder           Use DER format for certificates to read from
Packit aea12f
       --priority=str         Priorities string
Packit aea12f
       --dhparams=file        DH params file to use
Packit aea12f
                                - file must pre-exist
Packit aea12f
       --x509cafile=str       Certificate file or PKCS #11 URL to use
Packit aea12f
       --x509crlfile=file     CRL file to use
Packit aea12f
                                - file must pre-exist
Packit aea12f
       --x509keyfile=str      X.509 key file or PKCS #11 URL to use
Packit aea12f
                                - may appear multiple times
Packit aea12f
       --x509certfile=str     X.509 Certificate file or PKCS #11 URL to use
Packit aea12f
                                - may appear multiple times
Packit aea12f
       --srppasswd=file       SRP password file to use
Packit aea12f
                                - file must pre-exist
Packit aea12f
       --srppasswdconf=file   SRP password configuration file to use
Packit aea12f
                                - file must pre-exist
Packit aea12f
       --pskpasswd=file       PSK password file to use
Packit aea12f
                                - file must pre-exist
Packit aea12f
       --pskhint=str          PSK identity hint to use
Packit aea12f
       --ocsp-response=str    The OCSP response to send to client
Packit aea12f
                                - may appear multiple times
Packit aea12f
       --ignore-ocsp-response-errors  Ignore any errors when setting the OCSP response
Packit aea12f
   -p, --port=num             The port to connect to
Packit aea12f
   -l, --list                 Print a list of the supported algorithms and modes
Packit aea12f
   -!, --provider=file        Specify the PKCS #11 provider library
Packit aea12f
                                - file must pre-exist
Packit aea12f
   -", --keymatexport=str     Label used for exporting keying material
Packit aea12f
   -#, --keymatexportsize=num Size of the exported keying material
Packit aea12f
   -v, --version[=arg]        output version information and exit
Packit aea12f
   -h, --help                 display extended usage information and exit
Packit aea12f
   -!, --more-help            extended usage information passed thru pager
Packit aea12f
Packit aea12f
Options are specified by doubled hyphens and their name or by a single
Packit aea12f
hyphen and the flag character.
Packit aea12f
Packit aea12f
Server program that listens to incoming TLS connections.
Packit aea12f
Packit aea12f
@end example
Packit aea12f
@exampleindent 4
Packit aea12f
Packit aea12f
@anchor{gnutls-serv debug}
Packit aea12f
@subheading debug option (-d)
Packit aea12f
Packit aea12f
This is the ``enable debugging'' option.
Packit aea12f
This option takes a number argument.
Packit aea12f
Specifies the debug level.
Packit aea12f
@anchor{gnutls-serv sni-hostname}
Packit aea12f
@subheading sni-hostname option
Packit aea12f
Packit aea12f
This is the ``server's hostname for server name extension'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
Server name of type host_name that the server will recognise as its own. If the server receives client hello with different name, it will send a warning-level unrecognized_name alert.
Packit aea12f
@anchor{gnutls-serv alpn}
Packit aea12f
@subheading alpn option
Packit aea12f
Packit aea12f
This is the ``specify alpn protocol to be enabled by the server'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
Packit aea12f
@noindent
Packit aea12f
This option has some usage constraints.  It:
Packit aea12f
@itemize @bullet
Packit aea12f
@item
Packit aea12f
may appear an unlimited number of times.
Packit aea12f
@end itemize
Packit aea12f
Packit aea12f
Specify the (textual) ALPN protocol for the server to use.
Packit aea12f
@anchor{gnutls-serv require-client-cert}
Packit aea12f
@subheading require-client-cert option (-r)
Packit aea12f
Packit aea12f
This is the ``require a client certificate'' option.
Packit aea12f
This option before 3.6.0 used to imply --verify-client-cert.
Packit aea12f
Since 3.6.0 it will no longer verify the certificate by default.
Packit aea12f
@anchor{gnutls-serv verify-client-cert}
Packit aea12f
@subheading verify-client-cert option
Packit aea12f
Packit aea12f
This is the ``if a client certificate is sent then verify it.'' option.
Packit aea12f
Do not require, but if a client certificate is sent then verify it and close the connection if invalid.
Packit aea12f
@anchor{gnutls-serv heartbeat}
Packit aea12f
@subheading heartbeat option (-b)
Packit aea12f
Packit aea12f
This is the ``activate heartbeat support'' option.
Packit aea12f
Regularly ping client via heartbeat extension messages
Packit aea12f
@anchor{gnutls-serv priority}
Packit aea12f
@subheading priority option
Packit aea12f
Packit aea12f
This is the ``priorities string'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
TLS algorithms and protocols to enable. You can
Packit aea12f
use predefined sets of ciphersuites such as PERFORMANCE,
Packit aea12f
NORMAL, SECURE128, SECURE256. The default is NORMAL.
Packit aea12f
Packit aea12f
Check  the  GnuTLS  manual  on  section  ``Priority strings'' for more
Packit aea12f
information on allowed keywords
Packit aea12f
@anchor{gnutls-serv x509keyfile}
Packit aea12f
@subheading x509keyfile option
Packit aea12f
Packit aea12f
This is the ``x.509 key file or pkcs #11 url to use'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
Packit aea12f
@noindent
Packit aea12f
This option has some usage constraints.  It:
Packit aea12f
@itemize @bullet
Packit aea12f
@item
Packit aea12f
may appear an unlimited number of times.
Packit aea12f
@end itemize
Packit aea12f
Packit aea12f
Specify the private key file or URI to use; it must correspond to
Packit aea12f
the certificate specified in --x509certfile. Multiple keys and certificates
Packit aea12f
can be specified with this option and in that case each occurrence of keyfile
Packit aea12f
must be followed by the corresponding x509certfile or vice-versa.
Packit aea12f
@anchor{gnutls-serv x509certfile}
Packit aea12f
@subheading x509certfile option
Packit aea12f
Packit aea12f
This is the ``x.509 certificate file or pkcs #11 url to use'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
Packit aea12f
@noindent
Packit aea12f
This option has some usage constraints.  It:
Packit aea12f
@itemize @bullet
Packit aea12f
@item
Packit aea12f
may appear an unlimited number of times.
Packit aea12f
@end itemize
Packit aea12f
Packit aea12f
Specify the certificate file or URI to use; it must correspond to
Packit aea12f
the key specified in --x509keyfile. Multiple keys and certificates
Packit aea12f
can be specified with this option and in that case each occurrence of keyfile
Packit aea12f
must be followed by the corresponding x509certfile or vice-versa.
Packit aea12f
@anchor{gnutls-serv x509dsakeyfile}
Packit aea12f
@subheading x509dsakeyfile option
Packit aea12f
Packit aea12f
This is an alias for the @code{x509keyfile} option,
Packit aea12f
@pxref{gnutls-serv x509keyfile, the x509keyfile option documentation}.
Packit aea12f
Packit aea12f
@anchor{gnutls-serv x509dsacertfile}
Packit aea12f
@subheading x509dsacertfile option
Packit aea12f
Packit aea12f
This is an alias for the @code{x509certfile} option,
Packit aea12f
@pxref{gnutls-serv x509certfile, the x509certfile option documentation}.
Packit aea12f
Packit aea12f
@anchor{gnutls-serv x509ecckeyfile}
Packit aea12f
@subheading x509ecckeyfile option
Packit aea12f
Packit aea12f
This is an alias for the @code{x509keyfile} option,
Packit aea12f
@pxref{gnutls-serv x509keyfile, the x509keyfile option documentation}.
Packit aea12f
Packit aea12f
@anchor{gnutls-serv x509ecccertfile}
Packit aea12f
@subheading x509ecccertfile option
Packit aea12f
Packit aea12f
This is an alias for the @code{x509certfile} option,
Packit aea12f
@pxref{gnutls-serv x509certfile, the x509certfile option documentation}.
Packit aea12f
Packit aea12f
@anchor{gnutls-serv ocsp-response}
Packit aea12f
@subheading ocsp-response option
Packit aea12f
Packit aea12f
This is the ``the ocsp response to send to client'' option.
Packit aea12f
This option takes a string argument.
Packit aea12f
Packit aea12f
@noindent
Packit aea12f
This option has some usage constraints.  It:
Packit aea12f
@itemize @bullet
Packit aea12f
@item
Packit aea12f
may appear an unlimited number of times.
Packit aea12f
@end itemize
Packit aea12f
Packit aea12f
If the client requested an OCSP response, return data from this file to the client.
Packit aea12f
@anchor{gnutls-serv ignore-ocsp-response-errors}
Packit aea12f
@subheading ignore-ocsp-response-errors option
Packit aea12f
Packit aea12f
This is the ``ignore any errors when setting the ocsp response'' option.
Packit aea12f
That option instructs gnutls to not attempt to match the provided OCSP responses with the certificates.
Packit aea12f
@anchor{gnutls-serv list}
Packit aea12f
@subheading list option (-l)
Packit aea12f
Packit aea12f
This is the ``print a list of the supported algorithms and modes'' option.
Packit aea12f
Print a list of the supported algorithms and modes. If a priority string is given then only the enabled ciphersuites are shown.
Packit aea12f
@anchor{gnutls-serv provider}
Packit aea12f
@subheading provider option
Packit aea12f
Packit aea12f
This is the ``specify the pkcs #11 provider library'' option.
Packit aea12f
This option takes a file argument.
Packit aea12f
This will override the default options in /etc/gnutls/pkcs11.conf
Packit aea12f
@anchor{gnutls-serv exit status}
Packit aea12f
@subheading gnutls-serv exit status
Packit aea12f
Packit aea12f
One of the following exit values will be returned:
Packit aea12f
@table @samp
Packit aea12f
@item 0 (EXIT_SUCCESS)
Packit aea12f
Successful program execution.
Packit aea12f
@item 1 (EXIT_FAILURE)
Packit aea12f
The operation failed or the command syntax was not valid.
Packit aea12f
@end table
Packit aea12f
@anchor{gnutls-serv See Also}
Packit aea12f
@subheading gnutls-serv See Also
Packit aea12f
gnutls-cli-debug(1), gnutls-cli(1)
Packit aea12f
@anchor{gnutls-serv Examples}
Packit aea12f
@subheading gnutls-serv Examples
Packit aea12f
Running your own TLS server based on GnuTLS can be useful when
Packit aea12f
debugging clients and/or GnuTLS itself.  This section describes how to
Packit aea12f
use @code{gnutls-serv} as a simple HTTPS server.
Packit aea12f
Packit aea12f
The most basic server can be started as:
Packit aea12f
Packit aea12f
@example
Packit aea12f
gnutls-serv --http --priority "NORMAL:+ANON-ECDH:+ANON-DH"
Packit aea12f
@end example
Packit aea12f
Packit aea12f
It will only support anonymous ciphersuites, which many TLS clients
Packit aea12f
refuse to use.
Packit aea12f
Packit aea12f
The next step is to add support for X.509.  First we generate a CA:
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --generate-privkey > x509-ca-key.pem
Packit aea12f
$ echo 'cn = GnuTLS test CA' > ca.tmpl
Packit aea12f
$ echo 'ca' >> ca.tmpl
Packit aea12f
$ echo 'cert_signing_key' >> ca.tmpl
Packit aea12f
$ certtool --generate-self-signed --load-privkey x509-ca-key.pem \
Packit aea12f
  --template ca.tmpl --outfile x509-ca.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Then generate a server certificate.  Remember to change the dns_name
Packit aea12f
value to the name of your server host, or skip that command to avoid
Packit aea12f
the field.
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --generate-privkey > x509-server-key.pem
Packit aea12f
$ echo 'organization = GnuTLS test server' > server.tmpl
Packit aea12f
$ echo 'cn = test.gnutls.org' >> server.tmpl
Packit aea12f
$ echo 'tls_www_server' >> server.tmpl
Packit aea12f
$ echo 'encryption_key' >> server.tmpl
Packit aea12f
$ echo 'signing_key' >> server.tmpl
Packit aea12f
$ echo 'dns_name = test.gnutls.org' >> server.tmpl
Packit aea12f
$ certtool --generate-certificate --load-privkey x509-server-key.pem \
Packit aea12f
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
Packit aea12f
  --template server.tmpl --outfile x509-server.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
For use in the client, you may want to generate a client certificate
Packit aea12f
as well.
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --generate-privkey > x509-client-key.pem
Packit aea12f
$ echo 'cn = GnuTLS test client' > client.tmpl
Packit aea12f
$ echo 'tls_www_client' >> client.tmpl
Packit aea12f
$ echo 'encryption_key' >> client.tmpl
Packit aea12f
$ echo 'signing_key' >> client.tmpl
Packit aea12f
$ certtool --generate-certificate --load-privkey x509-client-key.pem \
Packit aea12f
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
Packit aea12f
  --template client.tmpl --outfile x509-client.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
To be able to import the client key/certificate into some
Packit aea12f
applications, you will need to convert them into a PKCS#12 structure.
Packit aea12f
This also encrypts the security sensitive key with a password.
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --to-p12 --load-ca-certificate x509-ca.pem \
Packit aea12f
  --load-privkey x509-client-key.pem --load-certificate x509-client.pem \
Packit aea12f
  --outder --outfile x509-client.p12
Packit aea12f
@end example
Packit aea12f
Packit aea12f
For icing, we'll create a proxy certificate for the client too.
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --generate-privkey > x509-proxy-key.pem
Packit aea12f
$ echo 'cn = GnuTLS test client proxy' > proxy.tmpl
Packit aea12f
$ certtool --generate-proxy --load-privkey x509-proxy-key.pem \
Packit aea12f
  --load-ca-certificate x509-client.pem --load-ca-privkey x509-client-key.pem \
Packit aea12f
  --load-certificate x509-client.pem --template proxy.tmpl \
Packit aea12f
  --outfile x509-proxy.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Then start the server again:
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ gnutls-serv --http \
Packit aea12f
            --x509cafile x509-ca.pem \
Packit aea12f
            --x509keyfile x509-server-key.pem \
Packit aea12f
            --x509certfile x509-server.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Try connecting to the server using your web browser.  Note that the
Packit aea12f
server listens to port 5556 by default.
Packit aea12f
Packit aea12f
While you are at it, to allow connections using ECDSA, you can also
Packit aea12f
create a ECDSA key and certificate for the server.  These credentials
Packit aea12f
will be used in the final example below.
Packit aea12f
Packit aea12f
@example
Packit aea12f
$ certtool --generate-privkey --ecdsa > x509-server-key-ecc.pem
Packit aea12f
$ certtool --generate-certificate --load-privkey x509-server-key-ecc.pem \
Packit aea12f
  --load-ca-certificate x509-ca.pem --load-ca-privkey x509-ca-key.pem \
Packit aea12f
  --template server.tmpl --outfile x509-server-ecc.pem
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Packit aea12f
The next step is to add support for SRP authentication. This requires
Packit aea12f
an SRP password file created with @code{srptool}.
Packit aea12f
To start the server with SRP support:
Packit aea12f
Packit aea12f
@example
Packit aea12f
gnutls-serv --http --priority NORMAL:+SRP-RSA:+SRP \
Packit aea12f
            --srppasswdconf srp-tpasswd.conf \
Packit aea12f
            --srppasswd srp-passwd.txt
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Let's also start a server with support for PSK. This would require
Packit aea12f
a password file created with @code{psktool}.
Packit aea12f
Packit aea12f
@example
Packit aea12f
gnutls-serv --http --priority NORMAL:+ECDHE-PSK:+PSK \
Packit aea12f
            --pskpasswd psk-passwd.txt
Packit aea12f
@end example
Packit aea12f
Packit aea12f
Finally, we start the server with all the earlier parameters and you
Packit aea12f
get this command:
Packit aea12f
Packit aea12f
@example
Packit aea12f
gnutls-serv --http --priority NORMAL:+PSK:+SRP \
Packit aea12f
            --x509cafile x509-ca.pem \
Packit aea12f
            --x509keyfile x509-server-key.pem \
Packit aea12f
            --x509certfile x509-server.pem \
Packit aea12f
            --x509keyfile x509-server-key-ecc.pem \
Packit aea12f
            --x509certfile x509-server-ecc.pem \
Packit aea12f
            --srppasswdconf srp-tpasswd.conf \
Packit aea12f
            --srppasswd srp-passwd.txt \
Packit aea12f
            --pskpasswd psk-passwd.txt
Packit aea12f
@end example