summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2014-07-13 23:17:29 +0000
committerjsing <>2014-07-13 23:17:29 +0000
commit90b541a2592f0fcd2c02ac451cfbc1cbdc345888 (patch)
tree10c93fe3f57aedfd81afcb7321f36d5a44350668 /src/lib
parent52d7e6dec2e1e75fcac1a3f02ca708176e0c1ee9 (diff)
downloadopenbsd-90b541a2592f0fcd2c02ac451cfbc1cbdc345888.tar.gz
openbsd-90b541a2592f0fcd2c02ac451cfbc1cbdc345888.tar.bz2
openbsd-90b541a2592f0fcd2c02ac451cfbc1cbdc345888.zip
Rename the context allocation from ressl_new to ressl_client, which makes
it completely obvious what the context is for. Ensure client functions are used on client contexts.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libressl/ressl.h2
-rw-r--r--src/lib/libressl/ressl_client.c23
-rw-r--r--src/lib/libressl/ressl_internal.h6
3 files changed, 30 insertions, 1 deletions
diff --git a/src/lib/libressl/ressl.h b/src/lib/libressl/ressl.h
index 766335aa0c..e7e0a9c51b 100644
--- a/src/lib/libressl/ressl.h
+++ b/src/lib/libressl/ressl.h
@@ -36,7 +36,7 @@ void ressl_config_set_verify_depth(struct ressl_config *config,
36void ressl_config_insecure_no_verify(struct ressl_config *config); 36void ressl_config_insecure_no_verify(struct ressl_config *config);
37void ressl_config_verify(struct ressl_config *config); 37void ressl_config_verify(struct ressl_config *config);
38 38
39struct ressl *ressl_new(void); 39struct ressl *ressl_client(void);
40int ressl_configure(struct ressl *ctx, struct ressl_config *config); 40int ressl_configure(struct ressl *ctx, struct ressl_config *config);
41void ressl_reset(struct ressl *ctx); 41void ressl_reset(struct ressl *ctx);
42void ressl_free(struct ressl *ctx); 42void ressl_free(struct ressl *ctx);
diff --git a/src/lib/libressl/ressl_client.c b/src/lib/libressl/ressl_client.c
index 2e4f253856..1d1ad72b86 100644
--- a/src/lib/libressl/ressl_client.c
+++ b/src/lib/libressl/ressl_client.c
@@ -28,6 +28,19 @@
28#include <ressl.h> 28#include <ressl.h>
29#include "ressl_internal.h" 29#include "ressl_internal.h"
30 30
31struct ressl *
32ressl_client(void)
33{
34 struct ressl *ctx;
35
36 if ((ctx = ressl_new()) == NULL)
37 return (NULL);
38
39 ctx->flags |= RESSL_CLIENT;
40
41 return (ctx);
42}
43
31int 44int
32ressl_connect(struct ressl *ctx, const char *host, const char *port) 45ressl_connect(struct ressl *ctx, const char *host, const char *port)
33{ 46{
@@ -36,6 +49,11 @@ ressl_connect(struct ressl *ctx, const char *host, const char *port)
36 char *hs = NULL, *ps = NULL; 49 char *hs = NULL, *ps = NULL;
37 int rv = -1, s = -1, ret; 50 int rv = -1, s = -1, ret;
38 51
52 if ((ctx->flags & RESSL_CLIENT) == 0) {
53 ressl_set_error(ctx, "not a client context");
54 goto err;
55 }
56
39 if (host == NULL) { 57 if (host == NULL) {
40 ressl_set_error(ctx, "host not specified"); 58 ressl_set_error(ctx, "host not specified");
41 goto err; 59 goto err;
@@ -108,6 +126,11 @@ ressl_connect_socket(struct ressl *ctx, int socket, const char *hostname)
108 X509 *cert = NULL; 126 X509 *cert = NULL;
109 int ret; 127 int ret;
110 128
129 if ((ctx->flags & RESSL_CLIENT) == 0) {
130 ressl_set_error(ctx, "not a client context");
131 goto err;
132 }
133
111 ctx->socket = socket; 134 ctx->socket = socket;
112 135
113 /* XXX - add a configuration option to control versions. */ 136 /* XXX - add a configuration option to control versions. */
diff --git a/src/lib/libressl/ressl_internal.h b/src/lib/libressl/ressl_internal.h
index f4eec10e63..260ae8e1f9 100644
--- a/src/lib/libressl/ressl_internal.h
+++ b/src/lib/libressl/ressl_internal.h
@@ -33,8 +33,12 @@ struct ressl_config {
33 int verify_depth; 33 int verify_depth;
34}; 34};
35 35
36#define RESSL_CLIENT (1 << 0)
37#define RESSL_SERVER (1 << 1)
38
36struct ressl { 39struct ressl {
37 struct ressl_config *config; 40 struct ressl_config *config;
41 uint64_t flags;
38 42
39 int err; 43 int err;
40 char *errmsg; 44 char *errmsg;
@@ -45,6 +49,8 @@ struct ressl {
45 SSL_CTX *ssl_ctx; 49 SSL_CTX *ssl_ctx;
46}; 50};
47 51
52struct ressl *ressl_new(void);
53
48int ressl_check_hostname(X509 *cert, const char *host); 54int ressl_check_hostname(X509 *cert, const char *host);
49int ressl_host_port(const char *hostport, char **host, char **port); 55int ressl_host_port(const char *hostport, char **host, char **port);
50int ressl_set_error(struct ressl *ctx, char *fmt, ...); 56int ressl_set_error(struct ressl *ctx, char *fmt, ...);