Blame include/apr_ldap_option.h

Packit 383869
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 383869
 * contributor license agreements.  See the NOTICE file distributed with
Packit 383869
 * this work for additional information regarding copyright ownership.
Packit 383869
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 383869
 * (the "License"); you may not use this file except in compliance with
Packit 383869
 * the License.  You may obtain a copy of the License at
Packit 383869
 *
Packit 383869
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 383869
 *
Packit 383869
 * Unless required by applicable law or agreed to in writing, software
Packit 383869
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 383869
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 383869
 * See the License for the specific language governing permissions and
Packit 383869
 * limitations under the License.
Packit 383869
 */
Packit 383869
Packit 383869
/**
Packit 383869
 * @file apr_ldap_option.h
Packit 383869
 * @brief  APR-UTIL LDAP ldap_*_option() functions
Packit 383869
 */
Packit 383869
#ifndef APR_LDAP_OPTION_H
Packit 383869
#define APR_LDAP_OPTION_H
Packit 383869
Packit 383869
/**
Packit 383869
 * @addtogroup APR_Util_LDAP
Packit 383869
 * @{
Packit 383869
 */
Packit 383869
Packit 383869
#include "apr_ldap.h"
Packit 383869
Packit 383869
#if APR_HAS_LDAP
Packit 383869
Packit 383869
#ifdef __cplusplus
Packit 383869
extern "C" {
Packit 383869
#endif /* __cplusplus */
Packit 383869
Packit 383869
/*
Packit 383869
 * The following defines handle the different TLS certificate
Packit 383869
 * options available. If these options are missing, APR will try and
Packit 383869
 * emulate support for this using the deprecated ldap_start_tls_s()
Packit 383869
 * function.
Packit 383869
 */
Packit 383869
/**
Packit 383869
 * Set SSL mode to one of APR_LDAP_NONE, APR_LDAP_SSL, APR_LDAP_STARTTLS
Packit 383869
 * or APR_LDAP_STOPTLS.
Packit 383869
 */
Packit 383869
#define APR_LDAP_OPT_TLS 0x6fff
Packit 383869
/**
Packit 383869
 * Set zero or more CA certificates, client certificates or private
Packit 383869
 * keys globally, or per connection (where supported).
Packit 383869
 */
Packit 383869
#define APR_LDAP_OPT_TLS_CERT 0x6ffe
Packit 383869
/**
Packit 383869
 * Set the LDAP library to no verify the server certificate.  This means
Packit 383869
 * all servers are considered trusted.
Packit 383869
 */
Packit 383869
#define APR_LDAP_OPT_VERIFY_CERT 0x6ffd
Packit 383869
/**
Packit 383869
 * Set the LDAP library to indicate if referrals should be chased during
Packit 383869
 * LDAP searches.
Packit 383869
 */
Packit 383869
#define APR_LDAP_OPT_REFERRALS 0x6ffc
Packit 383869
/**
Packit 383869
 * Set the LDAP library to indicate a maximum number of referral hops to
Packit 383869
 * chase before giving up on the search.
Packit 383869
 */
Packit 383869
#define APR_LDAP_OPT_REFHOPLIMIT 0x6ffb
Packit 383869
Packit 383869
/**
Packit 383869
 * Structures for the apr_set_option() cases
Packit 383869
 */
Packit 383869
Packit 383869
/**
Packit 383869
 * APR_LDAP_OPT_TLS_CERT
Packit 383869
 *
Packit 383869
 * This structure includes possible options to set certificates on
Packit 383869
 * system initialisation. Different SDKs have different certificate
Packit 383869
 * requirements, and to achieve this multiple certificates must be
Packit 383869
 * specified at once passed as an (apr_array_header_t *).
Packit 383869
 *
Packit 383869
 * Netscape:
Packit 383869
 * Needs the CA cert database (cert7.db), the client cert database (key3.db)
Packit 383869
 * and the security module file (secmod.db) set at the system initialisation
Packit 383869
 * time. Three types are supported: APR_LDAP_CERT7_DB, APR_LDAP_KEY3_DB and
Packit 383869
 * APR_LDAP_SECMOD.
Packit 383869
 *
Packit 383869
 * To specify a client cert connection, a certificate nickname needs to be
Packit 383869
 * provided with a type of APR_LDAP_CERT.
Packit 383869
 * int ldapssl_enable_clientauth( LDAP *ld, char *keynickname,
Packit 383869
 * char *keypasswd, char *certnickname );
Packit 383869
 * keynickname is currently not used, and should be set to ""
Packit 383869
 *
Packit 383869
 * Novell:
Packit 383869
 * Needs CA certificates and client certificates set at system initialisation
Packit 383869
 * time. Three types are supported: APR_LDAP_CA*, APR_LDAP_CERT* and
Packit 383869
 * APR_LDAP_KEY*.
Packit 383869
 *
Packit 383869
 * Certificates cannot be specified per connection.
Packit 383869
 *
Packit 383869
 * The functions used are:
Packit 383869
 * ldapssl_add_trusted_cert(serverTrustedRoot, serverTrustedRootEncoding);
Packit 383869
 * Clients certs and keys are set at system initialisation time with
Packit 383869
 * int ldapssl_set_client_cert (
Packit 383869
 *  void   *cert,
Packit 383869
 *  int     type
Packit 383869
 *  void   *password); 
Packit 383869
 * type can be LDAPSSL_CERT_FILETYPE_B64 or LDAPSSL_CERT_FILETYPE_DER
Packit 383869
 *  ldapssl_set_client_private_key(clientPrivateKey,
Packit 383869
 *                                 clientPrivateKeyEncoding,
Packit 383869
 *                                 clientPrivateKeyPassword);
Packit 383869
 *
Packit 383869
 * OpenSSL:
Packit 383869
 * Needs one or more CA certificates to be set at system initialisation time
Packit 383869
 * with a type of APR_LDAP_CA*.
Packit 383869
 *
Packit 383869
 * May have one or more client certificates set per connection with a type of
Packit 383869
 * APR_LDAP_CERT*, and keys with APR_LDAP_KEY*.
Packit 383869
 */
Packit 383869
/** CA certificate type unknown */
Packit 383869
#define APR_LDAP_CA_TYPE_UNKNOWN    0
Packit 383869
/** binary DER encoded CA certificate */
Packit 383869
#define APR_LDAP_CA_TYPE_DER        1
Packit 383869
/** PEM encoded CA certificate */
Packit 383869
#define APR_LDAP_CA_TYPE_BASE64     2
Packit 383869
/** Netscape/Mozilla cert7.db CA certificate database */
Packit 383869
#define APR_LDAP_CA_TYPE_CERT7_DB   3
Packit 383869
/** Netscape/Mozilla secmod file */
Packit 383869
#define APR_LDAP_CA_TYPE_SECMOD     4
Packit 383869
/** Client certificate type unknown */
Packit 383869
#define APR_LDAP_CERT_TYPE_UNKNOWN  5
Packit 383869
/** binary DER encoded client certificate */
Packit 383869
#define APR_LDAP_CERT_TYPE_DER      6
Packit 383869
/** PEM encoded client certificate */
Packit 383869
#define APR_LDAP_CERT_TYPE_BASE64   7
Packit 383869
/** Netscape/Mozilla key3.db client certificate database */
Packit 383869
#define APR_LDAP_CERT_TYPE_KEY3_DB  8
Packit 383869
/** Netscape/Mozilla client certificate nickname */
Packit 383869
#define APR_LDAP_CERT_TYPE_NICKNAME 9
Packit 383869
/** Private key type unknown */
Packit 383869
#define APR_LDAP_KEY_TYPE_UNKNOWN   10
Packit 383869
/** binary DER encoded private key */
Packit 383869
#define APR_LDAP_KEY_TYPE_DER       11
Packit 383869
/** PEM encoded private key */
Packit 383869
#define APR_LDAP_KEY_TYPE_BASE64    12
Packit 383869
/** PKCS#12 encoded client certificate */
Packit 383869
#define APR_LDAP_CERT_TYPE_PFX      13
Packit 383869
/** PKCS#12 encoded private key */
Packit 383869
#define APR_LDAP_KEY_TYPE_PFX       14
Packit 383869
/** Openldap directory full of base64-encoded cert 
Packit 383869
 * authorities with hashes in corresponding .0 directory
Packit 383869
 */
Packit 383869
#define APR_LDAP_CA_TYPE_CACERTDIR_BASE64 15
Packit 383869
Packit 383869
Packit 383869
/**
Packit 383869
 * Certificate structure.
Packit 383869
 *
Packit 383869
 * This structure is used to store certificate details. An array of
Packit 383869
 * these structures is passed to apr_ldap_set_option() to set CA
Packit 383869
 * and client certificates.
Packit 383869
 * @param type Type of certificate APR_LDAP_*_TYPE_*
Packit 383869
 * @param path Path, file or nickname of the certificate
Packit 383869
 * @param password Optional password, can be NULL
Packit 383869
 */
Packit 383869
typedef struct apr_ldap_opt_tls_cert_t apr_ldap_opt_tls_cert_t;
Packit 383869
struct apr_ldap_opt_tls_cert_t {
Packit 383869
    int type;
Packit 383869
    const char *path;
Packit 383869
    const char *password;
Packit 383869
};
Packit 383869
Packit 383869
/**
Packit 383869
 * APR_LDAP_OPT_TLS
Packit 383869
 *
Packit 383869
 * This sets the SSL level on the LDAP handle.
Packit 383869
 *
Packit 383869
 * Netscape/Mozilla:
Packit 383869
 * Supports SSL, but not STARTTLS
Packit 383869
 * SSL is enabled by calling ldapssl_install_routines().
Packit 383869
 *
Packit 383869
 * Novell:
Packit 383869
 * Supports SSL and STARTTLS.
Packit 383869
 * SSL is enabled by calling ldapssl_install_routines(). Note that calling
Packit 383869
 * other ldap functions before ldapssl_install_routines() may cause this
Packit 383869
 * function to fail.
Packit 383869
 * STARTTLS is enabled by calling ldapssl_start_tls_s() after calling
Packit 383869
 * ldapssl_install_routines() (check this).
Packit 383869
 *
Packit 383869
 * OpenLDAP:
Packit 383869
 * Supports SSL and supports STARTTLS, but none of this is documented:
Packit 383869
 * http://www.openldap.org/lists/openldap-software/200409/msg00618.html
Packit 383869
 * Documentation for both SSL support and STARTTLS has been deleted from
Packit 383869
 * the OpenLDAP documentation and website.
Packit 383869
 */
Packit 383869
Packit 383869
/** No encryption */
Packit 383869
#define APR_LDAP_NONE 0
Packit 383869
/** SSL encryption (ldaps://) */
Packit 383869
#define APR_LDAP_SSL 1
Packit 383869
/** TLS encryption (STARTTLS) */
Packit 383869
#define APR_LDAP_STARTTLS 2
Packit 383869
/** end TLS encryption (STOPTLS) */
Packit 383869
#define APR_LDAP_STOPTLS 3
Packit 383869
Packit 383869
/**
Packit 383869
 * APR LDAP get option function
Packit 383869
 *
Packit 383869
 * This function gets option values from a given LDAP session if
Packit 383869
 * one was specified. It maps to the native ldap_get_option() function.
Packit 383869
 * @param pool The pool to use
Packit 383869
 * @param ldap The LDAP handle
Packit 383869
 * @param option The LDAP_OPT_* option to return
Packit 383869
 * @param outvalue The value returned (if any)
Packit 383869
 * @param result_err The apr_ldap_err_t structure contained detailed results
Packit 383869
 *        of the operation.
Packit 383869
 */
Packit 383869
APU_DECLARE_LDAP(int) apr_ldap_get_option(apr_pool_t *pool,
Packit 383869
                                          LDAP *ldap,
Packit 383869
                                          int option,
Packit 383869
                                          void *outvalue,
Packit 383869
                                          apr_ldap_err_t **result_err);
Packit 383869
Packit 383869
/**
Packit 383869
 * APR LDAP set option function
Packit 383869
 * 
Packit 383869
 * This function sets option values to a given LDAP session if
Packit 383869
 * one was specified. It maps to the native ldap_set_option() function.
Packit 383869
 * 
Packit 383869
 * Where an option is not supported by an LDAP toolkit, this function
Packit 383869
 * will try and apply legacy functions to achieve the same effect,
Packit 383869
 * depending on the platform.
Packit 383869
 * @param pool The pool to use
Packit 383869
 * @param ldap The LDAP handle
Packit 383869
 * @param option The LDAP_OPT_* option to set
Packit 383869
 * @param invalue The value to set
Packit 383869
 * @param result_err The apr_ldap_err_t structure contained detailed results
Packit 383869
 *        of the operation.
Packit 383869
 */
Packit 383869
APU_DECLARE_LDAP(int) apr_ldap_set_option(apr_pool_t *pool,
Packit 383869
                                          LDAP *ldap,
Packit 383869
                                          int option,
Packit 383869
                                          const void *invalue,
Packit 383869
                                          apr_ldap_err_t **result_err);
Packit 383869
Packit 383869
#ifdef __cplusplus
Packit 383869
}
Packit 383869
#endif
Packit 383869
Packit 383869
#endif /* APR_HAS_LDAP */
Packit 383869
Packit 383869
/** @} */
Packit 383869
Packit 383869
#endif /* APR_LDAP_OPTION_H */
Packit 383869