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,
28 struct berval ** rspdata,
29 LDAPControl ***rspctrls,
34 if ( reqdata != NULL ) {
35 /* no request data should be provided */
36 return LDAP_PROTOCOL_ERROR;
39 /* can't start TLS if it is already started */
40 if (conn->c_is_tls != 0)
41 return(LDAP_OPERATIONS_ERROR);
43 /* fail if TLS could not be initialized */
44 if (ldap_pvt_tls_get_option(NULL, LDAP_OPT_X_TLS_CERT, &ctx) != 0
47 if (default_referral != NULL) {
48 /* caller will put the referral into the result */
49 return(LDAP_REFERRAL);
51 return(LDAP_UNAVAILABLE);
54 /* can't start TLS if there are other op's around */
55 if (conn->c_ops != NULL) {
56 if (conn->c_ops != op || op->o_next != NULL)
57 return(LDAP_OPERATIONS_ERROR);
59 if (conn->c_pending_ops != NULL) {
60 if (conn->c_pending_ops != op || op->o_next != NULL)
61 return(LDAP_OPERATIONS_ERROR);
65 conn->c_needs_tls_accept = 1;