Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1210032

Summary: Net::LDAP sets global SSL options that break further usage of SSL in the same script
Product: Red Hat Enterprise Linux 7 Reporter: Eric Eisenhart <eric.eisenhart>
Component: perl-LDAPAssignee: Jitka Plesnikova <jplesnik>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.1CC: brian.biggs, dkochuka, eric.eisenhart, jplesnik, mollo, ovasik, perl-maint-list, ppisar
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: perl-LDAP-0.56-5.el7 Doc Type: Bug Fix
Doc Text:
Cause: Net::LDAP sets global SSL options during connection. Consequence: Setting the global SSL option break further usage of SSL in the same script. Fix: Stop setting global SSL settings via IO::Socket::SSL::context_init() in Net::LDAP::start_tls(). Result: Successful connection and SSL/TLS verification.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 00:21:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1289025, 1305230    
Attachments:
Description Flags
Script that demonstrates the problem
none
Fix for LDAP.pm none

Description Eric Eisenhart 2015-04-08 17:42:03 UTC
Created attachment 1012341 [details]
Script that demonstrates the problem

Description of problem:
The version of Net::LDAP in the perl-LDAP package sets a global "SSL_verifycn_name" option in IO::Socket::SSL that causes any later SSL/TLS use (such as by LWP::UserAgent) to fail on verification.

Version-Release number of selected component (if applicable):
perl-LDAP-0.56-3.el7.noarch

Steps to Reproduce:
1. in a perl script, use Net::LDAP to connect to an ldap server with TLS enabled and certificate verified. Something like this:
my $ldap = Net::LDAP->new($ldaps_server);
my $msg = $ldap->start_tls(
  verify => 'require',
  cafile => '/etc/pki/tls/certs/ca-bundle.crt',
);

2. Later in that same perl script, do something else with SSL or TLS, such as use LWP to connect to an https URL, such as this:
my $lwp = LWP::UserAgent->new();
my $res = $lwp->get($https_url);
if ($res->is_success) {
  print "LWP connected to $https_url\n";
} else {
  print IO::Socket::SSL::errstr(),"\n";
  die $res->status_line;
}

Actual results:
IO::Socket::IP configuration failed SSL connect attempt failed with unknown error error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Expected results:
Successful connection and SSL/TLS verification.

Additional info:
This can be worked around by unsetting the global option in IO::Socket::SSL, like this:
IO::Socket::SSL::set_defaults(SSL_verifycn_name => undef);

If the same https connection is made prior to the ldap connection, there is no problem.

This workaround is not needed on RHEL6.6 or on Fedora 21.

I'm attaching a script that demonstrates the problem. Run with "--enableworkaround" to unset the variable.

Comment 2 Jitka Plesnikova 2015-04-09 09:17:46 UTC
Created attachment 1012598 [details]
Fix for LDAP.pm

Comment 3 Jitka Plesnikova 2015-04-09 09:21:28 UTC
The bug was reported to upstream and fix in release 0.57.

For more information:
https://rt.cpan.org/Public/Bug/Display.html?id=90459

The patch is attached.

Comment 7 Jitka Plesnikova 2016-03-04 14:59:03 UTC
How to test:

1) Install perl, perl-LDAP, perl-IO-Socket-SSL and perl-LWP-Protocol-https

2) Download and run the attached test script net-ldap-bug-demo.pl (attachment #1012341 [details])

3) The output does not contain any IO::Socket::IP failure.

Comment 11 errata-xmlrpc 2016-11-04 00:21:43 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2200.html