Pass a client identity to pt_tls_client, usable for TLS or SASL authentication

This commit is contained in:
Martin Willi
2013-02-28 16:46:07 +01:00
parent 55854ecc25
commit 806126eab2
2 changed files with 21 additions and 7 deletions
+13 -5
View File
@@ -48,7 +48,12 @@ struct private_pt_tls_client_t {
/** /**
* Server identity * Server identity
*/ */
identification_t *id; identification_t *server;
/**
* Client authentication identity
*/
identification_t *client;
/** /**
* Current PT-TLS message identifier * Current PT-TLS message identifier
@@ -77,7 +82,7 @@ static bool make_connection(private_pt_tls_client_t *this)
return FALSE; return FALSE;
} }
this->tls = tls_socket_create(FALSE, this->id, NULL, fd, NULL); this->tls = tls_socket_create(FALSE, this->server, this->client, fd, NULL);
if (!this->tls) if (!this->tls)
{ {
close(fd); close(fd);
@@ -283,14 +288,16 @@ METHOD(pt_tls_client_t, destroy, void,
close(fd); close(fd);
} }
this->address->destroy(this->address); this->address->destroy(this->address);
this->id->destroy(this->id); this->server->destroy(this->server);
this->client->destroy(this->client);
free(this); free(this);
} }
/** /**
* See header * See header
*/ */
pt_tls_client_t *pt_tls_client_create(host_t *address, identification_t *id) pt_tls_client_t *pt_tls_client_create(host_t *address, identification_t *server,
identification_t *client)
{ {
private_pt_tls_client_t *this; private_pt_tls_client_t *this;
@@ -300,7 +307,8 @@ pt_tls_client_t *pt_tls_client_create(host_t *address, identification_t *id)
.destroy = _destroy, .destroy = _destroy,
}, },
.address = address, .address = address,
.id = id, .server = server,
.client = client,
); );
return &this->public; return &this->public;
+8 -2
View File
@@ -50,10 +50,16 @@ struct pt_tls_client_t {
/** /**
* Create a pt_tls_client instance. * Create a pt_tls_client instance.
* *
* The client identity is used for:
* - TLS authentication if an appropirate certificate is found
* - SASL authentication if requested from the server
*
* @param address address/port to run assessments against, gets owned * @param address address/port to run assessments against, gets owned
* @param id server identity to use for authentication, gets owned * @param server server identity to use for authentication, gets owned
* @param client client identity to use for authentication, gets owned
* @return PT-TLS context * @return PT-TLS context
*/ */
pt_tls_client_t *pt_tls_client_create(host_t *address, identification_t *id); pt_tls_client_t *pt_tls_client_create(host_t *address, identification_t *server,
identification_t *client);
#endif /** PT_TLS_CLIENT_H_ @}*/ #endif /** PT_TLS_CLIENT_H_ @}*/