3 * Copyright 1999 The OpenLDAP Foundation.
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
15 #include <ac/socket.h>
23 SLAP_EXTOP_CALLBACK_FN cb,
27 struct berval * reqdata,
29 struct berval ** rspdata,
30 LDAPControl ***rspctrls,
32 struct berval *** refs )
36 if ( reqdata != NULL ) {
37 /* no request data should be provided */
38 return LDAP_PROTOCOL_ERROR;
41 /* can't start TLS if it is already started */
42 if (conn->c_is_tls != 0)
43 return(LDAP_OPERATIONS_ERROR);
45 /* fail if TLS could not be initialized */
46 if (ldap_pvt_tls_get_option(NULL, LDAP_OPT_X_TLS_CERT, &ctx) != 0
49 if (default_referral != NULL) {
50 /* caller will put the referral into the result */
51 return(LDAP_REFERRAL);
53 return(LDAP_UNAVAILABLE);
56 /* can't start TLS if there are other op's around */
57 if (conn->c_ops != NULL) {
58 if (conn->c_ops != op || op->o_next != NULL)
59 return(LDAP_OPERATIONS_ERROR);
61 if (conn->c_pending_ops != NULL) {
62 if (conn->c_pending_ops != op || op->o_next != NULL)
63 return(LDAP_OPERATIONS_ERROR);
67 conn->c_needs_tls_accept = 1;