@@ -83,6 +83,12 @@ This module defines the following functions:
83
83
This function sets the value of the global option specified by *option * to
84
84
*invalue *.
85
85
86
+ .. note ::
87
+
88
+ Most global settings do not affect existing :py:class: `LDAPObject `
89
+ connections. Applications should call :py:func: `set_option() ` before
90
+ they establish connections with :py:func: `initialize `.
91
+
86
92
.. versionchanged :: 3.1
87
93
88
94
The deprecated functions ``ldap.init() `` and ``ldap.open() `` were removed.
@@ -221,34 +227,156 @@ SASL options
221
227
TLS options
222
228
:::::::::::
223
229
230
+ .. warning ::
231
+
232
+ libldap does not materialize all TLS settings immediately. You must use
233
+ :py:const: `OPT_X_TLS_NEWCTX ` with value ``0 `` to instruct libldap to
234
+ apply pending TLS settings and create a new internal TLS context::
235
+
236
+ conn = ldap.initialize("ldap://ldap.example")
237
+ conn.set_option(ldap.OPT_X_TLS_CACERTFILE, '/path/to/ca.pem')
238
+ conn.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
239
+ conn.start_tls_s()
240
+ conn.simple_bind_s(dn, password)
241
+
224
242
.. py :data :: OPT_X_TLS
225
243
244
+ .. deprecated :: 3.0
245
+ The option is deprecated in OpenLDAP and should no longer be used. It
246
+ will be removed in the future.
247
+
248
+ .. py :data :: OPT_X_TLS_ALL
249
+
250
+ Value for :py:const: `OPT_X_TLS_CRLCHECK `
251
+
226
252
.. py :data :: OPT_X_TLS_ALLOW
227
253
254
+ Value for :py:const: `OPT_X_TLS_REQUIRE_CERT `
255
+
228
256
.. py :data :: OPT_X_TLS_CACERTDIR
229
257
258
+ get/set path to directory with CA certs
259
+
230
260
.. py :data :: OPT_X_TLS_CACERTFILE
231
261
262
+ get/set path to PEM file with CA certs
263
+
232
264
.. py :data :: OPT_X_TLS_CERTFILE
233
265
266
+ get/set path to file with PEM encoded cert for client cert authentication,
267
+ requires :py:const: `OPT_X_TLS_KEYFILE `.
268
+
269
+ .. py :data :: OPT_X_TLS_CIPHER
270
+
271
+ get cipher suite name from TLS session
272
+
234
273
.. py :data :: OPT_X_TLS_CIPHER_SUITE
235
274
275
+ get/set allowed cipher suites
276
+
277
+ .. py :data :: OPT_X_TLS_CRLCHECK
278
+
279
+ get/set CRL check mode. CRL validation needs :py:const: `OPT_X_TLS_CRLFILE `
280
+
281
+ :py:const: `OPT_X_TLS_NONE `
282
+ Don't perform CRL checks
283
+
284
+ :py:const: `OPT_X_TLS_PEER `
285
+ Perform CRL check for peer's end entity cert.
286
+
287
+ :py:const: `OPT_X_TLS_ALL `
288
+ Perform CRL checks for the whole cert chain
289
+
290
+ .. py :data :: OPT_X_TLS_CRLFILE
291
+
292
+ get/set path to CRL file
293
+
236
294
.. py :data :: OPT_X_TLS_CTX
237
295
296
+ get address of internal memory address of TLS context (**DO NOT USE **)
297
+
238
298
.. py :data :: OPT_X_TLS_DEMAND
239
299
300
+ Value for :py:const: `OPT_X_TLS_REQUIRE_CERT `
301
+
240
302
.. py :data :: OPT_X_TLS_HARD
241
303
304
+ Value for :py:const: `OPT_X_TLS_REQUIRE_CERT `
305
+
242
306
.. py :data :: OPT_X_TLS_KEYFILE
243
307
308
+ get/set path to file with PEM encoded key for client cert authentication,
309
+ requires :py:const: `OPT_X_TLS_CERTFILE `.
310
+
244
311
.. py :data :: OPT_X_TLS_NEVER
245
312
313
+ Value for :py:const: `OPT_X_TLS_REQUIRE_CERT `
314
+
315
+ .. py :data :: OPT_X_TLS_NEWCTX
316
+
317
+ set and apply TLS settings to internal TLS context. Value ``0 `` creates
318
+ a new client-side context.
319
+
320
+ .. py :data :: OPT_X_TLS_NONE
321
+
322
+ Value for :py:const: `OPT_X_TLS_CRLCHECK `
323
+
324
+ .. py :data :: OPT_X_TLS_PACKAGE
325
+
326
+ Get TLS implementation, known values are
327
+
328
+ * ``GnuTLS ``
329
+ * ``MozNSS `` (Mozilla NSS)
330
+ * ``OpenSSL ``
331
+
332
+ .. py :data :: OPT_X_TLS_PEER
333
+
334
+ Value for :py:const: `OPT_X_TLS_CRLCHECK `
335
+
336
+ .. py :data :: OPT_X_TLS_PEERCERT
337
+
338
+ Get peer's certificate as BER/DER data structure (not supported)
339
+
340
+ .. py :data :: OPT_X_TLS_PROTOCOL_MIN
341
+
342
+ get/set minimum protocol version (wire protocol version as int)
343
+
344
+ * ``0x300 `` for SSL 3.0
345
+ * ``0x301 `` for TLS 1.0
346
+ * ``0x302 `` for TLS 1.1
347
+ * ``0x303 `` for TLS 1.2
348
+ * ``0x304 `` for TLS 1.3
349
+
246
350
.. py :data :: OPT_X_TLS_RANDOM_FILE
247
351
352
+ get/set path to /dev/urandom (**DO NOT USE **)
353
+
248
354
.. py :data :: OPT_X_TLS_REQUIRE_CERT
249
355
356
+ get/set validation strategy for server cert.
357
+
358
+ :py:const: `OPT_X_TLS_NEVER `
359
+ Don't check server cert and host name
360
+
361
+ :py:const: `OPT_X_TLS_ALLOW `
362
+ Ignore cert validation errors and don't check host name
363
+
364
+ :py:const: `OPT_X_TLS_DEMAND `
365
+ Validate peer cert chain and host name
366
+
367
+ :py:const: `OPT_X_TLS_HARD `
368
+ Same as :py:const: `OPT_X_TLS_DEMAND `
369
+
250
370
.. py :data :: OPT_X_TLS_TRY
251
371
372
+ .. deprecated :: 3.0
373
+ This value is only used by slapd server internally. It will be removed
374
+ in the future.
375
+
376
+ .. py :data :: OPT_X_TLS_VERSION
377
+
378
+ Get negotiated TLS protocol version as string
379
+
252
380
.. _ldap-keepalive-options :
253
381
254
382
Keepalive options
@@ -561,6 +689,8 @@ The above exceptions are raised when a result code from an underlying API
561
689
call does not indicate success.
562
690
563
691
692
+ .. _ldap-warnings :
693
+
564
694
Warnings
565
695
========
566
696
0 commit comments