if ( tls_initialized )
return -1;
+ tls_initialized = 1;
#ifdef LDAP_R_COMPILE
tls_init_threads();
#endif
#endif
return 0;
error_exit:
+ if ( tls_def_ctx != NULL ) {
+ SSL_CTX_free( tls_def_ctx );
+ tls_def_ctx = NULL;
+ }
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &tls_def_ctx_mutex );
#endif
ber_len_t len;
extop_list_t *ext;
char *text;
+ struct berval **refs;
struct berval *rspdata;
LDAPControl **rspctrls;
oid, reqdata, &rspdata, &rspctrls, &text );
if( rc != SLAPD_ABANDON ) {
+ refs = NULL;
+ if (rc == LDAP_REFERRAL)
+ refs = default_referral;
+
send_ldap_extended( conn, op, rc, NULL, text,
- oid, rspdata, rspctrls );
+ refs, oid, rspdata, rspctrls );
}
if ( rspdata != NULL )
LIBSLAPD_F (void) send_ldap_extended LDAP_P((
Connection *conn, Operation *op,
ber_int_t err, const char *matched,
- const char *text,
+ const char *text, struct berval **refs,
char *rspoid, struct berval *rspdata,
LDAPControl **ctrls ));
ber_int_t err,
const char *matched,
const char *text,
+ struct berval **refs,
char *rspoid,
struct berval *rspdata,
LDAPControl **ctrls
#endif
send_ldap_response( conn, op, tag, msgid,
- err, matched, text, NULL,
+ err, matched, text, refs,
rspoid, rspdata, NULL, ctrls );
}
LDAPControl ***rspctrls,
char ** text )
{
+ void *ctx;
+
if ( reqdata != NULL ) {
/* no request data should be provided */
return LDAP_PROTOCOL_ERROR;
if (conn->c_is_tls != 0)
return(LDAP_OPERATIONS_ERROR);
+ /* fail if TLS could not be initialized */
+ if (ldap_pvt_tls_get_option(NULL, LDAP_OPT_X_TLS_CERT, &ctx) != 0
+ || ctx == NULL)
+ {
+ if (default_referral != NULL) {
+ /* caller will put the referral into the result */
+ return(LDAP_REFERRAL);
+ }
+ return(LDAP_UNAVAILABLE);
+ }
+
/* can't start TLS if there are other op's around */
if (conn->c_ops != NULL) {
if (conn->c_ops != op || op->o_next != NULL)
return(LDAP_OPERATIONS_ERROR);
}
- /* here's some pseudo-code if HAVE_TLS is defined
- * but for some reason TLS is not available.
- */
- /*
- if (tls not really supported) {
- if (referral exists) {
- // caller will need to put the referral into the result
- return(LDAP_REFERRAL);
- }
- return(LDAP_UNAVAILABLE);
- }
- */
-
conn->c_is_tls = 1;
conn->c_needs_tls_accept = 1;
ber_int_t err,
const char *matched,
const char *text,
+ struct berval **refs,
char *rspoid,
struct berval *rspdata,
LDAPControl **ctrls