home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / _60D2C81F4FE77E6223DDBA055FB5CB9E < prev    next >
Text File  |  2007-11-01  |  8KB  |  241 lines

  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2.  * contributor license agreements.  See the NOTICE file distributed with
  3.  * this work for additional information regarding copyright ownership.
  4.  * The ASF licenses this file to You under the Apache License, Version 2.0
  5.  * (the "License"); you may not use this file except in compliance with
  6.  * the License.  You may obtain a copy of the License at
  7.  *
  8.  *     http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16.  
  17. /**
  18.  * @file apr_ldap_option.h
  19.  * @brief  APR-UTIL LDAP ldap_*_option() functions
  20.  */
  21. #ifndef APR_LDAP_OPTION_H
  22. #define APR_LDAP_OPTION_H
  23.  
  24. /**
  25.  * @defgroup APR_Util_LDAP LDAP
  26.  * @ingroup APR_Util
  27.  * @{
  28.  */
  29.  
  30. #include "apr_ldap.h"
  31.  
  32. #if APR_HAS_LDAP
  33.  
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif /* __cplusplus */
  37.  
  38. /*
  39.  * The following defines handle the different TLS certificate
  40.  * options available. If these options are missing, APR will try and
  41.  * emulate support for this using the deprecated ldap_start_tls_s()
  42.  * function.
  43.  */
  44. /**
  45.  * Set SSL mode to one of APR_LDAP_NONE, APR_LDAP_SSL, APR_LDAP_STARTTLS
  46.  * or APR_LDAP_STOPTLS.
  47.  */
  48. #define APR_LDAP_OPT_TLS 0x6fff
  49. /**
  50.  * Set zero or more CA certificates, client certificates or private
  51.  * keys globally, or per connection (where supported).
  52.  */
  53. #define APR_LDAP_OPT_TLS_CERT 0x6ffe
  54. /**
  55.  * Set the LDAP library to no verify the server certificate.  This means
  56.  * all servers are considered trusted.
  57.  */
  58. #define APR_LDAP_OPT_VERIFY_CERT 0x6ffd
  59.  
  60. /**
  61.  * Structures for the apr_set_option() cases
  62.  */
  63.  
  64. /**
  65.  * APR_LDAP_OPT_TLS_CERT
  66.  *
  67.  * This structure includes possible options to set certificates on
  68.  * system initialisation. Different SDKs have different certificate
  69.  * requirements, and to achieve this multiple certificates must be
  70.  * specified at once passed as an (apr_array_header_t *).
  71.  *
  72.  * Netscape:
  73.  * Needs the CA cert database (cert7.db), the client cert database (key3.db)
  74.  * and the security module file (secmod.db) set at the system initialisation
  75.  * time. Three types are supported: APR_LDAP_CERT7_DB, APR_LDAP_KEY3_DB and
  76.  * APR_LDAP_SECMOD.
  77.  *
  78.  * To specify a client cert connection, a certificate nickname needs to be
  79.  * provided with a type of APR_LDAP_CERT.
  80.  * int ldapssl_enable_clientauth( LDAP *ld, char *keynickname,
  81.  * char *keypasswd, char *certnickname );
  82.  * keynickname is currently not used, and should be set to ""
  83.  *
  84.  * Novell:
  85.  * Needs CA certificates and client certificates set at system initialisation
  86.  * time. Three types are supported: APR_LDAP_CA*, APR_LDAP_CERT* and
  87.  * APR_LDAP_KEY*.
  88.  *
  89.  * Certificates cannot be specified per connection.
  90.  *
  91.  * The functions used are:
  92.  * ldapssl_add_trusted_cert(serverTrustedRoot, serverTrustedRootEncoding);
  93.  * Clients certs and keys are set at system initialisation time with
  94.  * int ldapssl_set_client_cert (
  95.  *  void   *cert,
  96.  *  int     type
  97.  *  void   *password); 
  98.  * type can be LDAPSSL_CERT_FILETYPE_B64 or LDAPSSL_CERT_FILETYPE_DER
  99.  *  ldapssl_set_client_private_key(clientPrivateKey,
  100.  *                                 clientPrivateKeyEncoding,
  101.  *                                 clientPrivateKeyPassword);
  102.  *
  103.  * OpenSSL:
  104.  * Needs one or more CA certificates to be set at system initialisation time
  105.  * with a type of APR_LDAP_CA*.
  106.  *
  107.  * May have one or more client certificates set per connection with a type of
  108.  * APR_LDAP_CERT*, and keys with APR_LDAP_KEY*.
  109.  */
  110. /** CA certificate type unknown */
  111. #define APR_LDAP_CA_TYPE_UNKNOWN    0
  112. /** binary DER encoded CA certificate */
  113. #define APR_LDAP_CA_TYPE_DER        1
  114. /** PEM encoded CA certificate */
  115. #define APR_LDAP_CA_TYPE_BASE64     2
  116. /** Netscape/Mozilla cert7.db CA certificate database */
  117. #define APR_LDAP_CA_TYPE_CERT7_DB   3
  118. /** Netscape/Mozilla secmod file */
  119. #define APR_LDAP_CA_TYPE_SECMOD     4
  120. /** Client certificate type unknown */
  121. #define APR_LDAP_CERT_TYPE_UNKNOWN  5
  122. /** binary DER encoded client certificate */
  123. #define APR_LDAP_CERT_TYPE_DER      6
  124. /** PEM encoded client certificate */
  125. #define APR_LDAP_CERT_TYPE_BASE64   7
  126. /** Netscape/Mozilla key3.db client certificate database */
  127. #define APR_LDAP_CERT_TYPE_KEY3_DB  8
  128. /** Netscape/Mozilla client certificate nickname */
  129. #define APR_LDAP_CERT_TYPE_NICKNAME 9
  130. /** Private key type unknown */
  131. #define APR_LDAP_KEY_TYPE_UNKNOWN   10
  132. /** binary DER encoded private key */
  133. #define APR_LDAP_KEY_TYPE_DER       11
  134. /** PEM encoded private key */
  135. #define APR_LDAP_KEY_TYPE_BASE64    12
  136. /** PKCS#12 encoded client certificate */
  137. #define APR_LDAP_CERT_TYPE_PFX      13
  138. /** PKCS#12 encoded private key */
  139. #define APR_LDAP_KEY_TYPE_PFX       14
  140.  
  141. /**
  142.  * Certificate structure.
  143.  *
  144.  * This structure is used to store certificate details. An array of
  145.  * these structures is passed to apr_ldap_set_option() to set CA
  146.  * and client certificates.
  147.  * @param type Type of certificate APR_LDAP_*_TYPE_*
  148.  * @param path Path, file or nickname of the certificate
  149.  * @param password Optional password, can be NULL
  150.  */
  151. typedef struct apr_ldap_opt_tls_cert_t apr_ldap_opt_tls_cert_t;
  152. struct apr_ldap_opt_tls_cert_t {
  153.     int type;
  154.     const char *path;
  155.     const char *password;
  156. };
  157.  
  158. /**
  159.  * APR_LDAP_OPT_TLS
  160.  *
  161.  * This sets the SSL level on the LDAP handle.
  162.  *
  163.  * Netscape/Mozilla:
  164.  * Supports SSL, but not STARTTLS
  165.  * SSL is enabled by calling ldapssl_install_routines().
  166.  *
  167.  * Novell:
  168.  * Supports SSL and STARTTLS.
  169.  * SSL is enabled by calling ldapssl_install_routines(). Note that calling
  170.  * other ldap functions before ldapssl_install_routines() may cause this
  171.  * function to fail.
  172.  * STARTTLS is enabled by calling ldapssl_start_tls_s() after calling
  173.  * ldapssl_install_routines() (check this).
  174.  *
  175.  * OpenLDAP:
  176.  * Supports SSL and supports STARTTLS, but none of this is documented:
  177.  * http://www.openldap.org/lists/openldap-software/200409/msg00618.html
  178.  * Documentation for both SSL support and STARTTLS has been deleted from
  179.  * the OpenLDAP documentation and website.
  180.  */
  181.  
  182. /** No encryption */
  183. #define APR_LDAP_NONE 0
  184. /** SSL encryption (ldaps://) */
  185. #define APR_LDAP_SSL 1
  186. /** TLS encryption (STARTTLS) */
  187. #define APR_LDAP_STARTTLS 2
  188. /** end TLS encryption (STOPTLS) */
  189. #define APR_LDAP_STOPTLS 3
  190.  
  191. /**
  192.  * APR LDAP get option function
  193.  *
  194.  * This function gets option values from a given LDAP session if
  195.  * one was specified. It maps to the native ldap_get_option() function.
  196.  * @param pool The pool to use
  197.  * @param ldap The LDAP handle
  198.  * @param option The LDAP_OPT_* option to return
  199.  * @param outvalue The value returned (if any)
  200.  * @param result_err The apr_ldap_err_t structure contained detailed results
  201.  *        of the operation.
  202.  */
  203. APU_DECLARE(int) apr_ldap_get_option(apr_pool_t *pool,
  204.                                      LDAP *ldap,
  205.                                      int option,
  206.                                      void *outvalue,
  207.                                      apr_ldap_err_t **result_err);
  208.  
  209. /**
  210.  * APR LDAP set option function
  211.  * 
  212.  * This function sets option values to a given LDAP session if
  213.  * one was specified. It maps to the native ldap_set_option() function.
  214.  * 
  215.  * Where an option is not supported by an LDAP toolkit, this function
  216.  * will try and apply legacy functions to achieve the same effect,
  217.  * depending on the platform.
  218.  * @param pool The pool to use
  219.  * @param ldap The LDAP handle
  220.  * @param option The LDAP_OPT_* option to set
  221.  * @param invalue The value to set
  222.  * @param result_err The apr_ldap_err_t structure contained detailed results
  223.  *        of the operation.
  224.  */
  225. APU_DECLARE(int) apr_ldap_set_option(apr_pool_t *pool,
  226.                                      LDAP *ldap,
  227.                                      int option,
  228.                                      const void *invalue,
  229.                                      apr_ldap_err_t **result_err);
  230.  
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234.  
  235. #endif /* APR_HAS_LDAP */
  236.  
  237. /** @} */
  238.  
  239. #endif /* APR_LDAP_OPTION_H */
  240.  
  241.