aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-11 14:58:09 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-16 08:45:11 -0800
commitbbf012364d9f1482b16c97b8bfd2fd07130446ca (patch)
tree2cb45903b0d5aa756d44f27b39a99c318a99a9a2 /src/supplemental/http/http.h
parent18229bbb69423d64d0a1b98bcf4bf3e24fba3aa4 (diff)
downloadnng-bbf012364d9f1482b16c97b8bfd2fd07130446ca.tar.gz
nng-bbf012364d9f1482b16c97b8bfd2fd07130446ca.tar.bz2
nng-bbf012364d9f1482b16c97b8bfd2fd07130446ca.zip
fixes #201 TLS configuration should support files for certificates and keys
This adds support for configuration of TLS websockets using the files for keys, certificates, and CRLs. Significant changes to the websocket, TLS, and HTTP layers were made here. We now expect TLS configuration to be tied to the HTTP layer, and the HTTP code creates default configuration objects based on the URL supplied. (HTTP dialers and listeners are now created with a URL rather than a sockaddr, giving them access to the scheme as well.) We fixed several bugs affecting TLS validation, and added a test suite that confirms that validation works as it should. We also fixed an orphaned socket during HTTP negotiation, responsible for an occasional assertion error if the http handshake does not complete successfully. Finally several use-after-free races were closed. TLS layer changes include reporting of handshake failures using newly created "standard" error codes for peer authentication and cryptographic failures. The use of the '*' wild card in URLs at bind time is no longer supported for websocket at least. Documentation updates for all this are in place as well.
Diffstat (limited to 'src/supplemental/http/http.h')
-rw-r--r--src/supplemental/http/http.h37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/supplemental/http/http.h b/src/supplemental/http/http.h
index 0f3affc0..06394fdd 100644
--- a/src/supplemental/http/http.h
+++ b/src/supplemental/http/http.h
@@ -222,11 +222,14 @@ typedef struct {
} nni_http_handler;
// nni_http_server will look for an existing server with the same
-// socket address, or create one if one does not exist. The servers
+// name and port, or create one if one does not exist. The servers
// are reference counted to permit sharing the server object across
-// multiple subsystems. The sockaddr matching is very limited though,
-// and the addresses must match *exactly*.
-extern int nni_http_server_init(nni_http_server **, nng_sockaddr *);
+// multiple subsystems. The URL hostname matching is very limited,
+// and the names must match *exactly* (without DNS resolution). Unless
+// a restricted binding is required, we recommend using a URL consisting
+// of an empty host name, such as http:// or https:// -- this would
+// convert to binding to the default port on all interfaces on the host.
+extern int nni_http_server_init(nni_http_server **, const char *);
// nni_http_server_fini drops the reference count on the server, and
// if this was the last reference, closes down the server and frees
@@ -245,9 +248,17 @@ extern void nni_http_server_del_handler(nni_http_server *, void *);
// nni_http_server_set_tls adds a TLS configuration to the server,
// and enables the use of it. This returns NNG_EBUSY if the server is
-// already started.
+// already started. This wipes out the entire TLS configuration on the
+// server client, so the caller must have configured it reasonably.
+// This API is not recommended unless the caller needs complete control
+// over the TLS configuration.
extern int nni_http_server_set_tls(nni_http_server *, nng_tls_config *);
+// nni_http_server_get_tls obtains the TLS configuration if one is present,
+// or returns NNG_EINVAL. The TLS configuration is invalidated if the
+// nni_http_server_set_tls function is called, so be careful.
+extern int nni_http_server_get_tls(nni_http_server *, nng_tls_config **);
+
// nni_http_server_start starts listening on the supplied port.
extern int nni_http_server_start(nni_http_server *);
@@ -279,9 +290,21 @@ extern int nni_http_server_add_file(nni_http_server *, const char *host,
typedef struct nni_http_client nni_http_client;
-extern int nni_http_client_init(nni_http_client **, nng_sockaddr *);
+// https vs. http; would also allow us to defer DNS lookups til later.
+extern int nni_http_client_init(nni_http_client **, const char *);
extern void nni_http_client_fini(nni_http_client *);
-extern int nni_http_client_set_tls(nni_http_client *, nng_tls_config *);
+
+// nni_http_client_set_tls sets the TLS configuration. This wipes out
+// the entire TLS configuration on the client, so the caller must have
+// configured it reasonably. This API is not recommended unless the
+// caller needs complete control over the TLS configuration.
+extern int nni_http_client_set_tls(nni_http_client *, nng_tls_config *);
+
+// nni_http_client_get_tls obtains the TLS configuration if one is present,
+// or returns NNG_EINVAL. The supplied TLS configuration object may
+// be invalidated by any future calls to nni_http_client_set_tls.
+extern int nni_http_client_get_tls(nni_http_client *, nng_tls_config **);
+
extern void nni_http_client_connect(nni_http_client *, nni_aio *);
#endif // NNG_SUPPLEMENTAL_HTTP_HTTP_H