From bdb38fdeb4183371b8ad8669c2821526133c39c8 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
@@ -53,9 +55,9 @@ library. 2.1.0.0 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the s6-dns libraries. -
+s6-networking
+Software
+skarnet.org
+
+ libsbearssl is a support library for the +s6-tlsc and +s6-tlsd executables when they're built +against the BearSSL +backend. Among other things, it offers interfaces to read private +keys and certificates from a Unix filesystem, which BearSSL does +not provide on its own. +
+ ++ BearSSL provides engines +to decode PEM objects and X.509 certificates, and to run a +TLS/SSL connection. However, it does not store such objects: +it never allocates memory, and does not interact with the +filesystem. sbearssl provides functions to +address this. +
+ ++ When reading an object into memory, sbearssl stores all +the bytes of the object in a +stralloc, +and the sbearssl_* structures contain indices of bytes in that +stralloc. That allows the structures to remain valid even when the stralloc +contents get reallocated and move to some other place in the heap. After +you have finished adding data to the stralloc and are sure its contents +will not move again, you can use the +sbearssl_*_to functions to convert sbearssl_* structures +to the corresponding br_* structures (native BearSSL), which +contain pointers to memory. +
+ ++ BearSSL handles two types of private keys: RSA keys and +EC keys (i.e. points on an elliptic curve). sbearssl +adds some generic functions to handle keys no matter their +type. +
+ + int sbearssl_rsa_skey_from (sbearssl_rsa_skey *l, br_rsa_private_key const *k, stralloc *sa)
+ Converts the RSA private key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_rsa_skey_to (sbearssl_rsa_skey const *l, br_rsa_private_key *k, char *s)
+ Converts the RSA private key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_ec_skey_from (sbearssl_ec_skey *l, br_ec_private_key const *k, stralloc *sa)
+ Converts the EC private key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_ec_skey_to (sbearssl_ec_skey const *l, br_ec_private_key *k, char *s)
+ Converts the EC private key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_skey_from (sbearssl_skey *l, br_skey const *k, stralloc *sa)
+ Converts the private key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_skey_to (sbearssl_skey const *l, br_skey *k, char *s)
+ Converts the private key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_skey_readfile (char const *fn, sbearssl_skey *key, stralloc *sa)
+ Reads a private key from the file named fn and stores it +in sbearssl format into the structure in *key, +the bytes of the key being added to the stralloc in *sa. +
+ ++The private key in fn can be either DER-encoded (binary format) +or PEM-encoded (text format). +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ ++ BearSSL handles two types of public keys: RSA keys and +EC keys (i.e. points on an elliptic curve). sbearssl +adds some generic functions to handle keys no matter their +type. +
+ ++ You normally should not handle public keys directly; +you should handle x509 certificate chains instead. +
+ + int sbearssl_rsa_pkey_from (sbearssl_rsa_pkey *l, br_rsa_public_key const *k, stralloc *sa)
+ Converts the RSA public key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_rsa_pkey_to (sbearssl_rsa_pkey const *l, br_rsa_public_key *k, char *s)
+ Converts the RSA public key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_ec_pkey_from (sbearssl_ec_skey *l, br_ec_public_key const *k, stralloc *sa)
+ Converts the EC public key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_ec_pkey_to (sbearssl_ec_pkey const *l, br_ec_public_key *k, char *s)
+ Converts the EC public key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_pkey_from (sbearssl_pkey *l, br_x509_pkey const *k, stralloc *sa)
+ Converts the public key from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_pkey_to (sbearssl_pkey const *l, br_x509_pkey *k, char *s)
+ Converts the public key from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ ++ You normally should not have to call these functions +directly. Instead, you should use the higher-level functions for +private keys, X509 certificate chains and trust anchors, which +will perform the PEM decoding for you. +
+ + int sbearssl_pem_decode_from_buffer (buffer *b, genalloc *list, stralloc *sa)
+ Decodes a PEM object, reading from the +buffer +in *b. The decoded bytes are appended to *sa. +list points to a +genalloc +containing objects of type sbearssl_pemobject. +One sbearssl_pemobject is appended to the genalloc per PEM entity +decoded from the byte stream read from the buffer. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ + int sbearssl_pem_decode_from_string (char const *s, size_t len, genalloc *list, stralloc *sa)
+ Decodes a PEM object from the len bytes pointed to by s. +The decoded bytes are appended to *sa. +list points to a +genalloc +containing objects of type sbearssl_pemobject. +One sbearssl_pemobject is appended to the genalloc per PEM entity +found in the bytes in s. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ + int sbearssl_cert_from (sbearssl_cert *l, br_x509_certificate const *k, stralloc *sa)
+ Converts a certificate from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_cert_to (sbearssl_cert const *l, br_x509_certificate *k, char *s)
+ Converts a certificate from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_cert_readfile (char const *fn, genalloc *list, stralloc *sa)
+ Reads one or more certificates from the file named fn and appends +them to the genalloc +in *list, which is a dynamically growing list of +sbearssl_cert structures. The bytes of the +(maybe PEM-decoded, but still DER-encoded) certificate are +appended to the stralloc in *sa. +
+ ++ The fn file can be either DER-encoded (binary format) +or PEM-encoded (text format). If it is DER-encoded, it must +contain exactly one X.509 certificate. If it is PEM-encoded, +it may contain a chain of certificates as long as the PEM +file fits within the size limits. +
+ ++ fn must not be bigger than SBEARSSL_MAXCERTFILESIZE, +which is 8 kB. This function is meant to read individual +certificates, not files containing large certificate chains or +sets of trust anchors. To do that, use +sbearssl_cert_readbigpem() instead. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ + int sbearssl_cert_readbigpem (char const *fn, genalloc *, stralloc *sa)
+ Reads one or more PEM-encoded certificates from the file named +fn and appends them to the +genalloc +in *list, which is a dynamically growing list of +sbearssl_cert structures. The bytes of the PEM-decoded (but +still DER-encoded) certificates are appended to the stralloc +in *sa. +
+ ++ The function will refuse to read a file that is not valid PEM. +Inside the file, It will ignore PEM objects that are +not X.509 certificates. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ ++ BearSSL clients do not use X.509-encoded certificates, +they use sets of trust anchors, i.e. structures +decoded from certificates representing (intermediate or) +root CAs. +
+ + int sbearssl_ta_from (sbearssl_ta *l, br_x509_trust_anchor const *k, stralloc *sa)
+ Converts a trust anchor from BearSSL format (reading from a structure pointed to by k) +to sbearssl format (writing to a structure pointed to by l). +The data from *k's contents are copied into the stralloc in *sa. +The function returns 1 on success and 0 (and sets errno) on failure. +
+ + void sbearssl_ta_to (sbearssl_ta const *l, br_x509_trust_anchor *k, char *s)
+ Converts a trust anchor from sbearssl format (reading from a structure pointed to by l) +to BearSSL format (writing to a structure pointed to by k). +The indices in l must refer to data stored in the string s. +
+ + int sbearssl_ta_readfile (char const *fn, genalloc *list, stralloc *sa)
+ Reads a set of trust anchors from a PEM file named fn +which must contain a list of (intermediate or) root CA certificates. +The trust anchors are appended to the +genalloc +in *list, which is a dynamically growing list of +sbearssl_ta structures. The contents of the trust anchors +are appended to *sa, which is a +stralloc +used for storage. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ + int sbearssl_ta_readdir (char const *dir, genalloc *list, stralloc *sa)
+ Reads a set of trust anchors from a directory named dir, +which must contain a list of (intermediate or) root CA certificates +stored as individual DER- or PEM-encoded files. +The trust anchors are appended to the +genalloc +in *list, which is a dynamically growing list of +sbearssl_ta structures. The contents of the trust anchors +are appended to *sa, which is a +stralloc +used for storage. +
+ ++ The function ignores files that do not contain valid DER +or PEM objects containing X.509 certificates representing +certification authorities. +
+ ++ The function returns 0 on success. It returns a negative value in +case of a system error, in which case errno identifies the +error. It returns a positive value in case of an error returned by +a BearSSL decoder, in which case an appropriate message can be +obtained with the sbearssl_error_str() function. +
+ ++ You probably shouldn't need to call any of these functions +directly, except for the first one. +
+ + char const *sbearssl_error_str (int err)
+ Returns a fixed string containing an error message corresponding +to the err code, which must be non-negative. The return +value from a few sbearssl functions, if positive, can be +interpreted via this function. +
+ + int sbearssl_isder (unsigned char const *s, size_t len)
+ Tests whether the array of len bytes pointed to by s +looks like a DER-encoded object. Returns 1 if it does and 0 otherwise. +
+ + int sbearssl_x509_minimal_set_tai (br_x509_minimal_context *ctx, tai_t t)
+ Sets the validation time for the X.509 context in *ctx to +the absolute time contained in *t, which is a +tai_t. +Returns 1 if it succeeds, or 0 if it fails - probably +because *t does not represent a valid time. +
+ + int sbearssl_x509_minimal_set_tain (br_x509_minimal_context *ctx, tain_t a)
+ Same as the above function, except the time is given as a +tain_t, +i.e. a tai_t plus nanoseconds (which are simply ignored). +
+ + + int sbearssl_run (br_ssl_engine_context *ctx, int *fds, unsigned int verbosity, uint32_t options, tain_t const *tto)
+ This function runs a full-duplex TLS/SSL engine, reading/writing +clear text from/to two file descriptors, and writing/reading +ciphertext to/from two other file descriptors, until the +connection is closed both ways (either with a SSL close, or +with EOF). +
+ ++ sbearssl_run will make the process die with an appropriate error +message if it encounters an unrecoverable error. If there were no problems +and the SSL/TLS connection closed cleanly, it returns 0. If a SSL/TLS-level +error occurred, it returns nonzero; a corresponding error message for the +return value can be obtained via sbearssl_error_str(). +All four descriptors in fds are closed when +sbearssl_run returns. +
+ + int sbearssl_s6tlsc (char const *const *argv, char const *const *envp, tain_t const *tto, uint32_t preoptions, uint32_t options, uid_t uid, gid_t gid, unsigned int verbosity, char const *servername, int *sfd)
+ This function implements s6-tlsc on top of BearSSL. +It has no other practical purpose; you're better off directly invoking +s6-tlsc. +
+ + int sbearssl_s6tlsd (char const *const *argv, char const *const *envp, tain_t const *tto, uint32_t preoptions, uint32_t options, uid_t uid, gid_t gid, unsigned int verbosity)
+ This function implements s6-tlsd on top of BearSSL. +It has no other practical purpose; you're better off directly invoking +s6-tlsd. +
+ + + diff --git a/doc/libstls/index.html b/doc/libstls/index.html new file mode 100644 index 0000000..4c6819b --- /dev/null +++ b/doc/libstls/index.html @@ -0,0 +1,127 @@ + + + + + +
+s6-networking
+Software
+skarnet.org
+
+ libstls is a small support library for the +s6-tlsc and +s6-tlsd executables when they're built +against the LibreSSL +backend. You can use it in your own programs, but since +libtls +is already relatively high-level, it's probably not very useful. +
+ + int stls_run (struct tls *ctx, int *fds, unsigned int verbosity, uint32_t options, tain_t const *tto)
+ This function runs a full-duplex TLS/SSL engine, reading/writing +clear text from/to two file descriptors, and writing/reading +ciphertext to/from two other file descriptors, until the +connection is closed both ways (either with a SSL close, or +with EOF). +
+ ++ stls_run will make the process die with an appropriate error +message if it encounters an error. If there were no problems and the +SSL/TLS connection closed cleanly, it returns 0. All four descriptors +in fds are closed when stls_run returns, but the +caller should still free ctx itself. +
+ + int stls_s6tlsc (char const *const *argv, char const *const *envp, tain_t const *tto, uint32_t preoptions, uint32_t options, uid_t uid, gid_t gid, unsigned int verbosity, char const *servername, int *sfd)
+ This function implements s6-tlsc on top of LibreSSL. +It has no other practical purpose; you're better off directly invoking +s6-tlsc. +
+ + int stls_s6tlsd (char const *const *argv, char const *const *envp, tain_t const *tto, uint32_t preoptions, uint32_t options, uid_t uid, gid_t gid, unsigned int verbosity)
+ This function implements s6-tlsd on top of LibreSSL. +It has no other practical purpose; you're better off directly invoking +s6-tlsd. +
+ + + diff --git a/doc/s6-tlsc.html b/doc/s6-tlsc.html new file mode 100644 index 0000000..b44caf5 --- /dev/null +++ b/doc/s6-tlsc.html @@ -0,0 +1,268 @@ + + + + + +
+s6-networking
+Software
+skarnet.org
+
+s6-tlsc is a program that establishes a TLS or SSL +client connection over an existing TCP connection, then spawns +an application. It is meant to make network communications +secure even for applications that do not natively support +TLS/SSL. +
+ ++ s6-networking does not include +cryptographic software. All the crypto used in s6-tlsc +is provided by the chosen SSL backend: +BearSSL or +LibreSSL, depending on +the options given when configuring s6-networking. +
+ ++ s6-tlsc [ -S | -s ] [ -Y | -y ] [ -Z | -z ] [ -v verbosity ] [ -K kimeout ] [ -k servername ] [ -6 rfd ] [ -7 wfd ] [ -- ] prog... ++ +
+ If the TLS/SSL connection closes cleanly, s6-tlsc +waits for prog to exit, then exits with an +approximation +of prog's exit code. +
+ ++ During the TLS/SSL handshake, s6-tlsc tries +every version of the protocol that is supported by the +backend, with all supported algorithms and cipher suites; +the backend normally ensures that the most secure combination +is tried first, with slow degradation until the client and +the server agree. +
+ ++ As a client, it is better for s6-tlsc to adapt to as many servers +as possible, that's why it adopts a liberal approach to protocol +versions. +
+ ++ s6-tlsc expects to have one of the +CADIR or CAFILE environment variables set. +It will refuse to run if both are unset. If both are set, +CADIR has priority. The value of that variable is: +
+ ++ If you are using client certificates, s6-tlsc also reads +two more environment variables: KEYFILE contains +the path to a file containing the private key, DER- or +PEM-encoded; and CERTFILE contains the path to +a file containing the client certificate, DER- or +PEM-encoded. Please note that for now, support for client +certificates is experimental, and only works +with the LibreSSL +backend (BearSSL does not support client certificates yet). +
+ ++ If s6-tlsc is run as root, it can also read two +other environment variables, TLS_UID and TLS_GID, +which contain a numeric uid and a numeric gid; s6-tlsc +then drops its root privileges to this uid/gid after spawning +prog.... This ensures that the TLS/engine and the +application run with different privileges. Note that prog... +should drop its own root privileges by its own means: the +s6-applyuidgid +program is a way of doing it. +
+ ++ Unless the -Z option has been given to +s6-tlsc, prog... is run with all the +TLS/SSL variables unset: CADIR, CAFILE, +KEYFILE, CERTFILE, TLS_UID and TLS_GID. The goal is +for s6-tlsc to be, by default, as invisible +as possible. +
+ ++ The -k servername option is important to +s6-tlsc: it tells it to send servername +as the name to require a certificate for. +Not setting this option allows s6-tlsc to +proceed without SNI, +which may be a security risk. +
+ ++ The s6-tlsclient program can +automatically craft a -k option for s6-tlsc +if the host argument that is given to it is a +host name. But if you're invoking s6-tlsc directly, +do not forget to give it this option. +
+ ++ If prog initiates the end of the session by sending +EOF, there are two ways for the TLS/SSL layer to handle it. +
+ ++ Nowadays (2016), most protocols are auto-terminated, so +it is not dangerous anymore to use EOF tranmission, and that +is the default fo s6-tlsc. Nevertheless, by +using the -S option, you can +force it to use the close_notify method if your +application requires it to be secure. +
+ +
+s6-networking
+Software
+skarnet.org
+
+s6-tlsclient is an +UCSPI client tool for +TLS/SSL connections over INET domain sockets. It establishes a TCP +connection to a server and a TLS transport over it, +then executes into a program. +
+ ++ s6-tlsclient [ options ] [ -- ] host port prog... ++ +
+ prog is expected to read from its peer on +descriptor 6 and write to its peer on descriptor 7. +Since there will be a s6-tlsc +program between prog and the network to perform +the SSL encryption/decryption, those descriptors will not +be a network socket - they will be pipes. +
+ ++ + If the -H option is not given to s6-tlsclient, +then host will be used as the server name to verify. +You can use the -k option to override this default. +Please note that if you use the -H option and do not +provide a server name via -k, SNI will not be +used, which may be a security risk. +
+ + ++ The following variables should be set before invoking +s6-tlsclient, because they will be used by +s6-tlsc: +
+ ++ Setting either CADIR or CAFILE is mandatory. +
+ ++ prog... is run with the following variables added to, +or removed from, its environment by s6-tcpclient: +
+ ++ Unless the -Z option is given to s6-tlsclient, +the CADIR, CAFILE, KEYFILE, CERTFILE, TLS_UID and TLS_GID +variables will not appear in prog's environment. +
+ + ++ s6-tlsclient accepts a myriad of options, most of which are +passed as is to the correct executable. Not giving any options will +generally work: the defaults are sensible. +
+ +
+ CADIR=/etc/ssl/certs s6-tlsclient skarnet.org 443 s6-ioconnect
+
+ This will open a connection to +the skarnet.org web server +over TLS and verify its certificate via the trust anchors +listed in the /etc/ssl/certs directory. It will then +branch your terminal to it: try typing +GET / HTTP/1.0 then hitting return twice. +
+ + + diff --git a/doc/s6-tlsd.html b/doc/s6-tlsd.html new file mode 100644 index 0000000..ab3243a --- /dev/null +++ b/doc/s6-tlsd.html @@ -0,0 +1,280 @@ + + + + + +
+s6-networking
+Software
+skarnet.org
+
+s6-tlsd is a program that performs the server side of +a TLS or SSL connection over an existing TCP connection, then spawns +an application. It is meant to make network communications +secure even for applications that do not natively support +TLS/SSL. +
+ ++ s6-networking does not include +cryptographic software. All the crypto used in s6-tlsc +is provided by the chosen SSL backend: +BearSSL or +LibreSSL, depending on +the options given when configuring s6-networking. +
+ ++ s6-tlsd [ -S | -s ] [ -Y | -y ] [ -Z | -z ] [ -v verbosity ] [ -K kimeout ] [ -- ] prog... ++ +
+ If the TLS/SSL connection closes cleanly, s6-tlsd +waits for prog to exit, then exits with an +approximation +of prog's exit code. +
+ ++ During the TLS/SSL handshake, s6-tlsd tries the +versions of the protocol that is supported by default by the +backend, with the default algorithms and cipher suites; +the backend normally ensures that the most secure combination +is tried first, with slow degradation until the client and +the server agree. +
+ ++ As a server, s6-tlsd can be conservative in its +choice of protocols. It is currently not very conservative +when using the BearSSL backend; it could become more so in +the future, by defining a custom server profile that supports +only TLS-1.2 but with several algorithms and cipher suites. +
+ ++ s6-tlsd expects to have the following +environment variables set: +
+ ++ If one of those variables is unset, s6-tlsd +will refuse to run. +
+ ++ If you are using client certificats, s6-tlsd +also requires either one of the following variables to be set: +
+ ++Please note that for now, support for client +certificates is experimental, and only works +with the LibreSSL +backend (BearSSL does not support client certificates yet). +
+ ++ If s6-tlsd is run as root, it can also read two +more environment variables, TLS_UID and TLS_GID, +which contain a numeric uid and a numeric gid; s6-tlsd +then drops its root privileges to this uid/gid after spawning +prog.... This ensures that the TLS/engine and the +application run with different privileges. +
+ ++ Note that prog... +should drop its own root privileges by its own means: the +s6-applyuidgid +program is a way of doing it. If the s6-tlsd +invocation actually comes from a +s6-tlsserver command line, +and privilege-dropping options (-G, -g, +-u or -U) have been given to +s6-tlsserver, then +s6-applyuidgid +directly follows s6-tlsd on the command line, in order +to also drop the child's privileges before executing the application. +The point of that setup is: +
+ ++ Unless the -Z option has been given to +s6-tlsd, prog... is run with all the +TLS/SSL variables unset: CADIR, CAFILE, +KEYFILE, CERTFILE, TLS_UID and TLS_GID. The goal is +for s6-tlsd to be, by default, as invisible +as possible. +
+ ++ If prog initiates the end of the session by sending +EOF, there are two ways for the TLS/SSL layer to handle it. +
+ ++ Nowadays (2016), most protocols are auto-terminated, so +it is not dangerous anymore to use EOF tranmission, and that +is the default fo s6-tlsd. Nevertheless, by +using the -S option, you can +force it to use the close_notify method if your +application requires it to be secure. +
+ +
+s6-networking
+Software
+skarnet.org
+
+s6-tlsserver is an +UCSPI server tool for +TLS/SSL connections over INET domain sockets. It acts as a TCP superserver +that listens to connections, accepts them, and for each connection, +establishes a TLS transport over it, then executes into a program. +
+ ++ s6-tlsserver [ options ] [ -- ] ip port prog... ++ +
+ prog is expected to read from its peer on its +standard input and write to its peer on its standard output. +Since there will be a s6-tlsd +program between prog and the network to perform +the SSL encryption/decryption, those descriptors will not +be a network socket - they will be pipes. +
+ ++ s6-tlsserver reacts to the same signals as +s6-tcpserver4d or +s6-tcpserver6d, +one of which is the long-lived process hanging around. +
+ ++ The following variables should be set before invoking +s6-tlsserver, because they will be used by +every s6-tlsd invocation: +
+ ++ Setting both KEYFILE and CERTFILE is mandatory. +
+ ++ prog... is run with the following variables added to, +or removed from, its environment by s6-tcpserver4d +or s6-tcpserver6d, and possibly +by s6-tcpserver-access: +
+ ++ Depending on TCP access rules (if the -i or -x +option has been given), it is possible that prog's +environment undergoes more modifications. Also, since +s6-tlsd is always run +after s6-tcpserver-access, +it is possible to set different TLS/SSL parameters (typically +a different KEYFILE and CERTFILE) depending on the client +connection, by writing the correct set of TCP access rules. +
+ ++ Unless the -Z option is given to s6-tlsserver, +the CADIR, CAFILE, KEYFILE, CERTFILE, TLS_UID and TLS_GID +variables will not appear in prog's environment. +
+ + ++ s6-tlsserver accepts a myriad of options, most of which are +passed as is to the correct executable. Not giving any options will +generally work, but unless you're running a very public server +(such as a Web server) or base your access control on client +certificates, you probably still want TCP access rules. +
+ +
+ As root:
+ KEYFILE=/etc/ssl/private/mykey.der CERTFILE=/etc/ssl/public/mycert.pem \
+ TLS_UID=65534 TLS_UID=65536 \
+ s6-envuidgid www
+ s6-tlsserver -U -- 1.2.3.4 443 httpd
+
+This will start a server listening to 1.2.3.4 on TCP port 443, + and for every connection, spawn the httpd program +reading queries on stdin and replying on stdout, as user www, +with a TLS layer protecting the connection, the TLS engine running +as user nobody (65534:65534). The server is +authentified by the certificate in /etc/ssl/public/mycert.pem +that it sends to the client, and the private key in +/etc/ssl/private/mykey.der that it keeps to itself. +
+ + + diff --git a/doc/upgrade.html b/doc/upgrade.html index 4b20888..b2cfe21 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -22,7 +22,7 @@