summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-09-29 15:11:29 +0000
committerjsing <>2014-09-29 15:11:29 +0000
commit0211c1396ff6d4dc401cabef56c2af3202f043f9 (patch)
tree50bbaa9e38aefb427b0f0162ccd9eefee6d46b85 /src
parentc9beabec633f1cc45215bc550b7370c475785a2b (diff)
downloadopenbsd-0211c1396ff6d4dc401cabef56c2af3202f043f9.tar.gz
openbsd-0211c1396ff6d4dc401cabef56c2af3202f043f9.tar.bz2
openbsd-0211c1396ff6d4dc401cabef56c2af3202f043f9.zip
Add an option that allows the enabled SSL protocols to be explicitly
configured. Discussed with several. ok bcook@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libressl/ressl.c19
-rw-r--r--src/lib/libressl/ressl.h13
-rw-r--r--src/lib/libressl/ressl_client.c7
-rw-r--r--src/lib/libressl/ressl_config.c12
-rw-r--r--src/lib/libressl/ressl_internal.h4
-rw-r--r--src/lib/libressl/ressl_server.c5
6 files changed, 51 insertions, 9 deletions
diff --git a/src/lib/libressl/ressl.c b/src/lib/libressl/ressl.c
index f01448b8f4..516afa53d6 100644
--- a/src/lib/libressl/ressl.c
+++ b/src/lib/libressl/ressl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl.c,v 1.14 2014/09/28 14:45:48 reyk Exp $ */ 1/* $OpenBSD: ressl.c,v 1.15 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -168,6 +168,23 @@ err:
168 return (1); 168 return (1);
169} 169}
170 170
171int
172ressl_configure_ssl(struct ressl *ctx)
173{
174 SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv2);
175
176 if ((ctx->config->protocols & RESSL_PROTOCOL_SSLv3) == 0)
177 SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_SSLv3);
178 if ((ctx->config->protocols & RESSL_PROTOCOL_TLSv1_0) == 0)
179 SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_TLSv1);
180 if ((ctx->config->protocols & RESSL_PROTOCOL_TLSv1_1) == 0)
181 SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_TLSv1_1);
182 if ((ctx->config->protocols & RESSL_PROTOCOL_TLSv1_2) == 0)
183 SSL_CTX_set_options(ctx->ssl_ctx, SSL_OP_NO_TLSv1_2);
184
185 return (0);
186}
187
171void 188void
172ressl_free(struct ressl *ctx) 189ressl_free(struct ressl *ctx)
173{ 190{
diff --git a/src/lib/libressl/ressl.h b/src/lib/libressl/ressl.h
index 90b51dc7fc..5d980f1f75 100644
--- a/src/lib/libressl/ressl.h
+++ b/src/lib/libressl/ressl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl.h,v 1.16 2014/09/28 15:08:01 jsing Exp $ */ 1/* $OpenBSD: ressl.h,v 1.17 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -18,6 +18,15 @@
18#ifndef HEADER_RESSL_H 18#ifndef HEADER_RESSL_H
19#define HEADER_RESSL_H 19#define HEADER_RESSL_H
20 20
21#define RESSL_PROTOCOL_SSLv3 (1 << 0)
22#define RESSL_PROTOCOL_TLSv1_0 (1 << 1)
23#define RESSL_PROTOCOL_TLSv1_1 (1 << 2)
24#define RESSL_PROTOCOL_TLSv1_2 (1 << 3)
25#define RESSL_PROTOCOL_TLSv1 \
26 (RESSL_PROTOCOL_TLSv1_0|RESSL_PROTOCOL_TLSv1_1|RESSL_PROTOCOL_TLSv1_2)
27#define RESSL_PROTOCOLS_DEFAULT \
28 (RESSL_PROTOCOL_SSLv3|RESSL_PROTOCOL_TLSv1)
29
21#define RESSL_READ_AGAIN -2 30#define RESSL_READ_AGAIN -2
22#define RESSL_WRITE_AGAIN -3 31#define RESSL_WRITE_AGAIN -3
23 32
@@ -43,6 +52,8 @@ int ressl_config_set_key_file(struct ressl_config *config,
43 const char *key_file); 52 const char *key_file);
44int ressl_config_set_key_mem(struct ressl_config *config, const uint8_t *key, 53int ressl_config_set_key_mem(struct ressl_config *config, const uint8_t *key,
45 size_t len); 54 size_t len);
55void ressl_config_set_protocols(struct ressl_config *config,
56 uint32_t protocols);
46void ressl_config_set_verify_depth(struct ressl_config *config, 57void ressl_config_set_verify_depth(struct ressl_config *config,
47 int verify_depth); 58 int verify_depth);
48 59
diff --git a/src/lib/libressl/ressl_client.c b/src/lib/libressl/ressl_client.c
index 5969a104f7..8723a35ae0 100644
--- a/src/lib/libressl/ressl_client.c
+++ b/src/lib/libressl/ressl_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl_client.c,v 1.3 2014/08/05 12:46:16 jsing Exp $ */ 1/* $OpenBSD: ressl_client.c,v 1.4 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -134,11 +134,14 @@ ressl_connect_socket(struct ressl *ctx, int socket, const char *hostname)
134 134
135 ctx->socket = socket; 135 ctx->socket = socket;
136 136
137 /* XXX - add a configuration option to control versions. */
138 if ((ctx->ssl_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) { 137 if ((ctx->ssl_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) {
139 ressl_set_error(ctx, "ssl context failure"); 138 ressl_set_error(ctx, "ssl context failure");
140 goto err; 139 goto err;
141 } 140 }
141
142 if (ressl_configure_ssl(ctx) != 0)
143 goto err;
144
142 if (ctx->config->verify) { 145 if (ctx->config->verify) {
143 if (hostname == NULL) { 146 if (hostname == NULL) {
144 ressl_set_error(ctx, "server name not specified"); 147 ressl_set_error(ctx, "server name not specified");
diff --git a/src/lib/libressl/ressl_config.c b/src/lib/libressl/ressl_config.c
index 106527c109..c92886330e 100644
--- a/src/lib/libressl/ressl_config.c
+++ b/src/lib/libressl/ressl_config.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl_config.c,v 1.11 2014/09/29 09:30:31 jsing Exp $ */ 1/* $OpenBSD: ressl_config.c,v 1.12 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -71,11 +71,13 @@ ressl_config_new(void)
71 ressl_config_free(config); 71 ressl_config_free(config);
72 return (NULL); 72 return (NULL);
73 } 73 }
74 ressl_config_verify(config); 74 ressl_config_set_protocols(config, RESSL_PROTOCOLS_DEFAULT);
75 ressl_config_set_verify_depth(config, 6); 75 ressl_config_set_verify_depth(config, 6);
76 /* ? use function ? */ 76 /* ? use function ? */
77 config->ecdhcurve = NID_X9_62_prime256v1; 77 config->ecdhcurve = NID_X9_62_prime256v1;
78 78
79 ressl_config_verify(config);
80
79 return (config); 81 return (config);
80} 82}
81 83
@@ -164,6 +166,12 @@ ressl_config_set_key_mem(struct ressl_config *config, const uint8_t *key,
164} 166}
165 167
166void 168void
169ressl_config_set_protocols(struct ressl_config *config, uint32_t protocols)
170{
171 config->protocols = protocols;
172}
173
174void
167ressl_config_set_verify_depth(struct ressl_config *config, int verify_depth) 175ressl_config_set_verify_depth(struct ressl_config *config, int verify_depth)
168{ 176{
169 config->verify_depth = verify_depth; 177 config->verify_depth = verify_depth;
diff --git a/src/lib/libressl/ressl_internal.h b/src/lib/libressl/ressl_internal.h
index 02dded3e7e..f37b5718d9 100644
--- a/src/lib/libressl/ressl_internal.h
+++ b/src/lib/libressl/ressl_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl_internal.h,v 1.10 2014/08/27 10:46:53 reyk Exp $ */ 1/* $OpenBSD: ressl_internal.h,v 1.11 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> 3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org>
4 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 4 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
@@ -36,6 +36,7 @@ struct ressl_config {
36 const char *key_file; 36 const char *key_file;
37 char *key_mem; 37 char *key_mem;
38 size_t key_len; 38 size_t key_len;
39 uint32_t protocols;
39 int verify; 40 int verify;
40 int verify_depth; 41 int verify_depth;
41}; 42};
@@ -63,6 +64,7 @@ struct ressl *ressl_server_conn(struct ressl *ctx);
63int ressl_check_hostname(X509 *cert, const char *host); 64int ressl_check_hostname(X509 *cert, const char *host);
64int ressl_configure_keypair(struct ressl *ctx); 65int ressl_configure_keypair(struct ressl *ctx);
65int ressl_configure_server(struct ressl *ctx); 66int ressl_configure_server(struct ressl *ctx);
67int ressl_configure_ssl(struct ressl *ctx);
66int ressl_host_port(const char *hostport, char **host, char **port); 68int ressl_host_port(const char *hostport, char **host, char **port);
67int ressl_set_error(struct ressl *ctx, char *fmt, ...); 69int ressl_set_error(struct ressl *ctx, char *fmt, ...);
68 70
diff --git a/src/lib/libressl/ressl_server.c b/src/lib/libressl/ressl_server.c
index 24b54ad0d0..e2dc7cf088 100644
--- a/src/lib/libressl/ressl_server.c
+++ b/src/lib/libressl/ressl_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl_server.c,v 1.7 2014/08/27 10:46:53 reyk Exp $ */ 1/* $OpenBSD: ressl_server.c,v 1.8 2014/09/29 15:11:29 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -52,12 +52,13 @@ ressl_configure_server(struct ressl *ctx)
52{ 52{
53 EC_KEY *ecdh_key; 53 EC_KEY *ecdh_key;
54 54
55 /* XXX - add a configuration option to control versions. */
56 if ((ctx->ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) { 55 if ((ctx->ssl_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) {
57 ressl_set_error(ctx, "ssl context failure"); 56 ressl_set_error(ctx, "ssl context failure");
58 goto err; 57 goto err;
59 } 58 }
60 59
60 if (ressl_configure_ssl(ctx) != 0)
61 goto err;
61 if (ressl_configure_keypair(ctx) != 0) 62 if (ressl_configure_keypair(ctx) != 0)
62 goto err; 63 goto err;
63 64