aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/tls
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-16 12:07:45 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-16 14:29:38 -0800
commit02e6153236ae744fb614fcd14184924ec85c2993 (patch)
tree6b41ca972d60e758c65c1adc0621500a92003c86 /src/supplemental/tls
parentbbf012364d9f1482b16c97b8bfd2fd07130446ca (diff)
downloadnng-02e6153236ae744fb614fcd14184924ec85c2993.tar.gz
nng-02e6153236ae744fb614fcd14184924ec85c2993.tar.bz2
nng-02e6153236ae744fb614fcd14184924ec85c2993.zip
fixes #206 Want NNG_OPT_TLS_VERIFIED option
It is useful to have support for validating that a peer *was* verified, especially in the presence of optional validation. We have added a property that does this, NNG_OPT_TLS_VERIFIED. Further, all the old NNG_OPT_WSS_TLS_* property names have also been renamed to generic NNG_OPT_TLS property names, which have been moved to nng.h to facilitate reuse and sharing, with the comments moved and corrected as well. Finally, the man pages have been updated, with substantial improvements to the nng_ws man page in particular.
Diffstat (limited to 'src/supplemental/tls')
-rw-r--r--src/supplemental/tls/mbedtls/tls.c4
-rw-r--r--src/supplemental/tls/tls.h4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/supplemental/tls/mbedtls/tls.c b/src/supplemental/tls/mbedtls/tls.c
index 4e846f98..7b959b2b 100644
--- a/src/supplemental/tls/mbedtls/tls.c
+++ b/src/supplemental/tls/mbedtls/tls.c
@@ -751,13 +751,13 @@ nni_tls_ciphersuite_name(nni_tls *tp)
return (mbedtls_ssl_get_ciphersuite(&tp->ctx));
}
-int
+bool
nni_tls_verified(nni_tls *tp)
{
int rv;
rv = mbedtls_ssl_get_verify_result(&tp->ctx);
- return (rv ? 1 : 0);
+ return (rv ? true : false);
}
int
diff --git a/src/supplemental/tls/tls.h b/src/supplemental/tls/tls.h
index 5fde50b4..57b552d7 100644
--- a/src/supplemental/tls/tls.h
+++ b/src/supplemental/tls/tls.h
@@ -11,6 +11,8 @@
#ifndef NNG_SUPPLEMENTAL_TLS_TLS_H
#define NNG_SUPPLEMENTAL_TLS_TLS_H
+#include <stdbool.h>
+
// nni_tls represents the context for a single TLS stream.
typedef struct nni_tls nni_tls;
@@ -41,7 +43,7 @@ extern int nni_tls_peername(nni_tls *, nni_sockaddr *);
// verify. (During the handshake phase, the peer is not verified, so this
// might return false if executed too soon. The verification status will
// be accurate once the handshake is finished, however.
-extern int nni_tls_verified(nni_tls *);
+extern bool nni_tls_verified(nni_tls *);
// nni_tls_ciphersuite_name returns the name of the ciphersuite in use.
extern const char *nni_tls_ciphersuite_name(nni_tls *);