Move ldap_start_tls_s() to tls.c

This commit is contained in:
Kurt Zeilenga 2000-08-25 02:16:15 +00:00
parent 5361dbe52c
commit a2afb207be
2 changed files with 44 additions and 46 deletions

View File

@ -240,47 +240,6 @@ ldap_initialize( LDAP **ldp, LDAP_CONST char *url )
return LDAP_SUCCESS;
}
int
ldap_start_tls_s ( LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls )
{
#ifdef HAVE_TLS
LDAPConn *lc;
int rc;
char *rspoid = NULL;
struct berval *rspdata = NULL;
if (ld->ld_conns == NULL) {
rc = ldap_open_defconn( ld );
if (rc != LDAP_SUCCESS)
return(rc);
}
for (lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next) {
if (ldap_pvt_tls_inplace(lc->lconn_sb) != 0)
return LDAP_OPERATIONS_ERROR;
/* XXYYZ: this initiates operaton only on default connection! */
rc = ldap_extended_operation_s(ld, LDAP_EXOP_START_TLS,
NULL, serverctrls, clientctrls, &rspoid, &rspdata);
if (rc != LDAP_SUCCESS)
return rc;
if (rspoid != NULL)
LDAP_FREE(rspoid);
if (rspdata != NULL)
ber_bvfree(rspdata);
rc = ldap_pvt_tls_start( ld, lc->lconn_sb, ld->ld_options.ldo_tls_ctx );
if (rc != LDAP_SUCCESS)
return rc;
}
return LDAP_SUCCESS;
#else
return LDAP_NOT_SUPPORTED;
#endif
}
int
ldap_int_open_connection(
LDAP *ld,

View File

@ -8,8 +8,6 @@
#include "portable.h"
#ifdef HAVE_TLS
#include <stdio.h>
#include <ac/stdlib.h>
@ -21,6 +19,8 @@
#include "ldap-int.h"
#ifdef HAVE_TLS
#ifdef LDAP_R_COMPILE
#include <ldap_pvt_thread.h>
#endif
@ -1033,7 +1033,46 @@ tls_tmp_dh_cb( SSL *ssl, int is_export, int key_length )
return NULL;
}
#endif
#else
static int dummy;
#endif
int
ldap_start_tls_s ( LDAP *ld,
LDAPControl **serverctrls,
LDAPControl **clientctrls )
{
#ifdef HAVE_TLS
LDAPConn *lc;
int rc;
char *rspoid = NULL;
struct berval *rspdata = NULL;
if (ld->ld_conns == NULL) {
rc = ldap_open_defconn( ld );
if (rc != LDAP_SUCCESS)
return(rc);
}
for (lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next) {
if (ldap_pvt_tls_inplace(lc->lconn_sb) != 0)
return LDAP_OPERATIONS_ERROR;
/* XXYYZ: this initiates operaton only on default connection! */
rc = ldap_extended_operation_s(ld, LDAP_EXOP_START_TLS,
NULL, serverctrls, clientctrls, &rspoid, &rspdata);
if (rc != LDAP_SUCCESS)
return rc;
if (rspoid != NULL)
LDAP_FREE(rspoid);
if (rspdata != NULL)
ber_bvfree(rspdata);
rc = ldap_pvt_tls_start( ld, lc->lconn_sb, ld->ld_options.ldo_tls_ctx );
if (rc != LDAP_SUCCESS)
return rc;
}
return LDAP_SUCCESS;
#else
return LDAP_NOT_SUPPORTED;
#endif
}