void canl_free_ctx(canl_ctx cc)
{
glb_ctx *ctx = (glb_ctx*) cc;
+ struct canl_mech *mech = find_mech(GSS_C_NO_OID);
if (!cc)
return;
ctx->err_msg = NULL;
}
/*TODO delete ctx content for real*/
+ if (mech)
+ mech->free_ctx(ctx);
+ if (ctx->err_msg){
+ free(ctx->err_msg);
+ ctx->err_msg = NULL;
+ }
free(ctx);
}
+
canl_err_code
canl_create_io_handler(canl_ctx cc, canl_io_handler *io)
{
err = mech->connect(glb_cc, io_cc, ctx, timeout, host);
if (err) {
canl_io_close(glb_cc, io_cc);
- mech->free_ctx(glb_cc, ctx);
+ mech->finish(glb_cc, ctx);
ctx = NULL;
continue;
}
if (err) {
(io_cc)->sock = -1;
if (conn_ctx)
- mech->free_ctx(glb_cc, conn_ctx);
+ mech->finish(glb_cc, conn_ctx);
}
return err;
if (io_cc->conn_ctx) {
mech = find_mech(io->oid);
- mech->free_ctx(cc, io_cc->conn_ctx);
+ mech->finish(cc, io_cc->conn_ctx);
io_cc->conn_ctx = NULL;
io_cc->oid = GSS_C_NO_OID;
}
(glb_ctx *, void **);
canl_err_code (*free_ctx)
- (glb_ctx *, void *);
+ (glb_ctx *);
canl_err_code (*connect)
(glb_ctx *, io_handler *, void *, struct timeval *, const char *);
}
static canl_err_code
-ssl_free(glb_ctx *cc, void *ctx)
+ssl_finish(glb_ctx *cc, void *ctx)
{
SSL_free(ctx);
return 0;
}
static canl_err_code
-ssl_finish(glb_ctx *cc, void *ctx)
+ssl_free_ctx(glb_ctx *cc)
{
- SSL_CTX_free(ctx);
+ mech_glb_ctx *m_ctx = cc->mech_ctx;
+ SSL_CTX_free(m_ctx->mech_ctx);
+ m_ctx->mech_ctx = NULL;
+
+ if (!m_ctx)
+ return 0;
+
+ if (m_ctx->ca_dir){
+ free(m_ctx->ca_dir);
+ m_ctx->ca_dir = NULL;
+ }
+ if (m_ctx->ca_file){
+ free(m_ctx->ca_file);
+ m_ctx->ca_file = NULL;
+ }
+ if (m_ctx->crl_dir){
+ free(m_ctx->crl_dir);
+ m_ctx->crl_dir = NULL;
+ }
+
+ if (m_ctx->cert_key){
+ if (m_ctx->cert_key->cert){
+ X509_free(m_ctx->cert_key->cert);
+ m_ctx->cert_key->cert = NULL;
+ }
+ if (m_ctx->cert_key->key){
+ EVP_PKEY_free(m_ctx->cert_key->key);
+ m_ctx->cert_key->key = NULL;
+ }
+ if (m_ctx->cert_key->chain){
+ sk_X509_pop_free(m_ctx->cert_key->chain, X509_free);
+ m_ctx->cert_key->chain = NULL;
+ }
+ free(m_ctx->cert_key);
+ m_ctx->cert_key = NULL;
+ }
+ free(m_ctx);
+ cc->mech_ctx = NULL;
return 0;
}
ssl_finish,
ssl_client_init,
ssl_server_init,
- ssl_free,
+ ssl_free_ctx,
ssl_connect,
ssl_accept,
ssl_close,