Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 Doc/reference/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ TLS options

.. py:data:: OPT_X_TLS_PEERCERT

Get peer's certificate as binary ASN.1 data structure (not supported)
Get peer's certificate as binary ASN.1 data structure

.. py:data:: OPT_X_TLS_PROTOCOL_MIN

Expand Down
17 changes: 16 additions & 1 deletion 17 Modules/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "LDAPObject.h"
#include "ldapcontrol.h"
#include "options.h"
#include "berval.h"

void
set_timeval_from_double(struct timeval *tv, double d)
Expand Down Expand Up @@ -235,6 +236,7 @@ LDAP_get_option(LDAPObject *self, int option)
{
int res;
int intval;
struct berval *bv;
struct timeval *tv;
LDAPAPIInfo apiinfo;
LDAPControl **lcs;
Expand Down Expand Up @@ -399,7 +401,20 @@ LDAP_get_option(LDAPObject *self, int option)
v = LDAPControls_to_List(lcs);
ldap_controls_free(lcs);
return v;

#ifdef LDAP_OPT_X_TLS_PEERCERT
case LDAP_OPT_X_TLS_PEERCERT:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this is only in openldap >=2.5.0

#endif
/* Berval-valued options */
res = LDAP_int_get_option(self, option, &bv);
if (res != LDAP_OPT_SUCCESS)
return option_error(res, "ldap_get_option");
if (bv == NULL) {
Py_INCREF(Py_None);
return Py_None;
}
v = LDAPberval_to_object(bv);
ldap_memfree(bv);
return v;
default:
PyErr_Format(PyExc_ValueError, "unknown option %d", option);
return NULL;
Expand Down
1 change: 1 addition & 0 deletions 1 Tests/t_ldapobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def test_multiple_starttls(self):
l.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
l.start_tls_s()
l.simple_bind_s(self.server.root_dn, self.server.root_pw)
self.assertEqual(l.get_option(ldap.OPT_X_TLS_PEERCERT), b"eg")
self.assertEqual(l.whoami_s(), 'dn:' + self.server.root_dn)

def test_dse(self):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.