File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -383,7 +383,7 @@ TLS options
383
383
384
384
.. py :data :: OPT_X_TLS_PEERCERT
385
385
386
- Get peer's certificate as binary ASN.1 data structure (not supported)
386
+ Get peer's certificate as binary ASN.1 data structure
387
387
388
388
.. py :data :: OPT_X_TLS_PROTOCOL_MIN
389
389
Original file line number Diff line number Diff line change 5
5
#include "LDAPObject.h"
6
6
#include "ldapcontrol.h"
7
7
#include "options.h"
8
+ #include "berval.h"
8
9
9
10
void
10
11
set_timeval_from_double (struct timeval * tv , double d )
@@ -235,6 +236,7 @@ LDAP_get_option(LDAPObject *self, int option)
235
236
{
236
237
int res ;
237
238
int intval ;
239
+ struct berval * bv ;
238
240
struct timeval * tv ;
239
241
LDAPAPIInfo apiinfo ;
240
242
LDAPControl * * lcs ;
@@ -399,7 +401,20 @@ LDAP_get_option(LDAPObject *self, int option)
399
401
v = LDAPControls_to_List (lcs );
400
402
ldap_controls_free (lcs );
401
403
return v ;
402
-
404
+ #ifdef LDAP_OPT_X_TLS_PEERCERT
405
+ case LDAP_OPT_X_TLS_PEERCERT :
406
+ #endif
407
+ /* Berval-valued options */
408
+ res = LDAP_int_get_option (self , option , & bv );
409
+ if (res != LDAP_OPT_SUCCESS )
410
+ return option_error (res , "ldap_get_option" );
411
+ if (bv == NULL ) {
412
+ Py_INCREF (Py_None );
413
+ return Py_None ;
414
+ }
415
+ v = LDAPberval_to_object (bv );
416
+ ldap_memfree (bv );
417
+ return v ;
403
418
default :
404
419
PyErr_Format (PyExc_ValueError , "unknown option %d" , option );
405
420
return NULL ;
Original file line number Diff line number Diff line change @@ -395,6 +395,7 @@ def test_multiple_starttls(self):
395
395
l .set_option (ldap .OPT_X_TLS_NEWCTX , 0 )
396
396
l .start_tls_s ()
397
397
l .simple_bind_s (self .server .root_dn , self .server .root_pw )
398
+ self .assertEqual (l .get_option (ldap .OPT_X_TLS_PEERCERT ), b"eg" )
398
399
self .assertEqual (l .whoami_s (), 'dn:' + self .server .root_dn )
399
400
400
401
def test_dse (self ):
You can’t perform that action at this time.
0 commit comments