diff options
Diffstat (limited to 'src/lib/libtls/tls_client.c')
-rw-r--r-- | src/lib/libtls/tls_client.c | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/src/lib/libtls/tls_client.c b/src/lib/libtls/tls_client.c index 81b5510431..056526ddc3 100644 --- a/src/lib/libtls/tls_client.c +++ b/src/lib/libtls/tls_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_client.c,v 1.23 2015/09/09 14:32:06 jsing Exp $ */ | 1 | /* $OpenBSD: tls_client.c,v 1.24 2015/09/09 19:23:04 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -21,7 +21,6 @@ | |||
21 | #include <arpa/inet.h> | 21 | #include <arpa/inet.h> |
22 | #include <netinet/in.h> | 22 | #include <netinet/in.h> |
23 | 23 | ||
24 | #include <limits.h> | ||
25 | #include <netdb.h> | 24 | #include <netdb.h> |
26 | #include <stdlib.h> | 25 | #include <stdlib.h> |
27 | #include <unistd.h> | 26 | #include <unistd.h> |
@@ -190,6 +189,8 @@ tls_connect_fds(struct tls *ctx, int fd_read, int fd_write, | |||
190 | 189 | ||
191 | if (tls_configure_ssl(ctx) != 0) | 190 | if (tls_configure_ssl(ctx) != 0) |
192 | goto err; | 191 | goto err; |
192 | if (tls_configure_keypair(ctx, 0) != 0) | ||
193 | goto err; | ||
193 | 194 | ||
194 | if (ctx->config->verify_name) { | 195 | if (ctx->config->verify_name) { |
195 | if (servername == NULL) { | 196 | if (servername == NULL) { |
@@ -198,30 +199,9 @@ tls_connect_fds(struct tls *ctx, int fd_read, int fd_write, | |||
198 | } | 199 | } |
199 | } | 200 | } |
200 | 201 | ||
201 | if (ctx->config->verify_cert) { | 202 | if (ctx->config->verify_cert && |
202 | SSL_CTX_set_verify(ctx->ssl_ctx, SSL_VERIFY_PEER, NULL); | 203 | (tls_configure_ssl_verify(ctx, SSL_VERIFY_PEER) == -1)) |
203 | 204 | goto err; | |
204 | if (ctx->config->ca_mem != NULL) { | ||
205 | if (ctx->config->ca_len > INT_MAX) { | ||
206 | tls_set_errorx(ctx, "ca too long"); | ||
207 | goto err; | ||
208 | } | ||
209 | |||
210 | if (SSL_CTX_load_verify_mem(ctx->ssl_ctx, | ||
211 | ctx->config->ca_mem, ctx->config->ca_len) != 1) { | ||
212 | tls_set_errorx(ctx, | ||
213 | "ssl verify memory setup failure"); | ||
214 | goto err; | ||
215 | } | ||
216 | } else if (SSL_CTX_load_verify_locations(ctx->ssl_ctx, | ||
217 | ctx->config->ca_file, ctx->config->ca_path) != 1) { | ||
218 | tls_set_errorx(ctx, "ssl verify setup failure"); | ||
219 | goto err; | ||
220 | } | ||
221 | if (ctx->config->verify_depth >= 0) | ||
222 | SSL_CTX_set_verify_depth(ctx->ssl_ctx, | ||
223 | ctx->config->verify_depth); | ||
224 | } | ||
225 | 205 | ||
226 | if ((ctx->ssl_conn = SSL_new(ctx->ssl_ctx)) == NULL) { | 206 | if ((ctx->ssl_conn = SSL_new(ctx->ssl_ctx)) == NULL) { |
227 | tls_set_errorx(ctx, "ssl connection failure"); | 207 | tls_set_errorx(ctx, "ssl connection failure"); |