Skip to content

Commit

Permalink
lib-ssl-iostream: move ssl_iostream_settings_dup to iostream-ssl.c
Browse files Browse the repository at this point in the history
  • Loading branch information
mrannanj authored and GitLab committed May 7, 2016
1 parent 2795f61 commit 173d1d7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/lib-ssl-iostream/iostream-openssl-context.c
Expand Up @@ -225,23 +225,6 @@ ssl_iostream_ctx_verify_remote_cert(struct ssl_iostream_context *ctx,
SSL_CTX_set_client_CA_list(ctx->ssl_ctx, ca_names);
}

static struct ssl_iostream_settings *
ssl_iostream_settings_dup(pool_t pool,
const struct ssl_iostream_settings *old_set)
{
struct ssl_iostream_settings *new_set;

new_set = p_new(pool, struct ssl_iostream_settings, 1);
new_set->protocols = p_strdup(pool, old_set->protocols);
new_set->cipher_list = p_strdup(pool, old_set->cipher_list);
new_set->cert = p_strdup(pool, old_set->cert);
new_set->key = p_strdup(pool, old_set->key);
new_set->key_password = p_strdup(pool, old_set->key_password);

new_set->verbose = old_set->verbose;
return new_set;
}

#ifdef HAVE_SSL_GET_SERVERNAME
static int ssl_servername_callback(SSL *ssl, int *al ATTR_UNUSED,
void *context ATTR_UNUSED)
Expand Down
23 changes: 23 additions & 0 deletions src/lib-ssl-iostream/iostream-ssl.c
Expand Up @@ -216,3 +216,26 @@ const char *ssl_iostream_get_last_error(struct ssl_iostream *ssl_io)
{
return ssl_vfuncs->get_last_error(ssl_io);
}

struct ssl_iostream_settings *
ssl_iostream_settings_dup(pool_t pool,
const struct ssl_iostream_settings *old_set)
{
struct ssl_iostream_settings *new_set;

new_set = p_new(pool, struct ssl_iostream_settings, 1);
memcpy(new_set, old_set, sizeof(*new_set));

new_set->protocols = p_strdup(pool, old_set->protocols);
new_set->cipher_list = p_strdup(pool, old_set->cipher_list);
new_set->ca = p_strdup(pool, old_set->ca);
new_set->ca_file = p_strdup(pool, old_set->ca_file);
new_set->ca_dir = p_strdup(pool, old_set->ca_dir);
new_set->cert = p_strdup(pool, old_set->cert);
new_set->key = p_strdup(pool, old_set->key);
new_set->key_password = p_strdup(pool, old_set->key_password);
new_set->cert_username_field = p_strdup(pool, old_set->cert_username_field);
new_set->crypto_device = p_strdup(pool, old_set->crypto_device);

return new_set;
}
2 changes: 2 additions & 0 deletions src/lib-ssl-iostream/iostream-ssl.h
Expand Up @@ -77,5 +77,7 @@ int ssl_iostream_context_init_server(const struct ssl_iostream_settings *set,
struct ssl_iostream_context **ctx_r,
const char **error_r);
void ssl_iostream_context_deinit(struct ssl_iostream_context **ctx);
struct ssl_iostream_settings *ssl_iostream_settings_dup(pool_t pool,
const struct ssl_iostream_settings *old_set);

#endif

0 comments on commit 173d1d7

Please sign in to comment.