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 1490392 - xmlrpclib does not support SSL context, needed for SSL verification
Summary: xmlrpclib does not support SSL context, needed for SSL verification
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python
Version: 7.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Charalampos Stratakis
QA Contact: Mirek Długosz
URL:
Whiteboard:
Depends On:
Blocks: 1527012
TreeView+ depends on / blocked
 
Reported: 2017-09-11 12:56 UTC by Rik Theys
Modified: 2018-04-10 15:00 UTC (History)
7 users (show)

Fixed In Version: python-2.7.5-62.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 15:00:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0833 0 None None None 2018-04-10 15:00:55 UTC

Internal Links: 1527012

Description Rik Theys 2017-09-11 12:56:18 UTC
Description of problem:
RHEL 7.4 enabled SSL verification by default for Python 2.7.

This feature was backported from python 2.7.9. However, python 2.7.9 supports "context" parameters for the xmlrpclib.ServerProxy class, which was not backported.

This means that with the new default of verifying SSL certificates, it is not possible to specify a custom CAfile for xmlrpclib connections as the context parameter is unknown.

It is also not known to the SafeTransport class, so this workaround can also not be used.


Version-Release number of selected component (if applicable):
python-2.7.5-58.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. Try to connect to an https xmlrpc server with a custom CA store
2.
3.

Actual results:

Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> import xmlrpclib
>>> ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH, cafile="test.crt")
>>> s = xmlrpclib.ServerProxy("https://internal.server.com", context=ctx)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'context'
>>> s = xmlrpclib.ServerProxy("https://internal.server.com", transport=xmlrpclib.SafeTransport(context=ctx))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: __init__() got an unexpected keyword argument 'context'
>>> 


Expected results:
That the context parameter is known by either the ServerProxy class or the SafeTransport class.


Additional info:

Comment 2 Charalampos Stratakis 2017-09-14 15:35:16 UTC
Hello.

It is possible to disable the certificate verification by using the config file /etc/python/cert-verification.cfg as it is described here [0].

I believe that is the upstream issue for that bug [1]. Will dig a bit further.

[0] https://access.redhat.com/articles/2039753

[1] https://bugs.python.org/issue22960

Comment 3 Rik Theys 2017-09-14 18:43:30 UTC
Hi,

I am aware that I can disable it system-wide, but it would disable it for all scripts.

The bug you refer to has been fixed and newer versions of the 2.7 series support additional "context" parameters to most functions that could use https.

It seems only the certificate validation feature was backported, but not the extra parameters on those functions.

As you see in the documentation for current 2.7 versions, xmlrpclib.ServerProxy supports a "context" parameter:

https://docs.python.org/2.7/library/xmlrpclib.html

Regards,

Rik

Comment 5 Dan Callaghan 2017-10-17 09:00:27 UTC
I don't think this patch was backported properly. With python-2.7.5-62.el7.x86_64 I get this exception:

Python 2.7.5 (default, Oct 11 2017, 10:12:42) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpclib
>>> s = xmlrpclib.ServerProxy('https://beaker.engineering.redhat.com/')
>>> s.auth.who_am_i()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1591, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1273, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1293, in single_request
    h = self.make_connection(host)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1509, in make_connection
    self._connection = host, HTTPS(chost, None, context=context, **(x509 or {}))
NameError: global name 'context' is not defined

A Beaker user reported this as it breaks beaker-client which uses xmlrpclib.

Comment 6 Dan Callaghan 2017-10-17 09:03:18 UTC
I am guessing in this hunk of the offending patch:

 63 @@ -1493,7 +1497,7 @@ class SafeTransport(Transport):
 64                  )
 65          else:
 66              chost, self._extra_headers, x509 = self.get_host_info(host)
 67 -            self._connection = host, HTTPS(chost, None, **(x509 or {}))
 68 +            self._connection = host, HTTPS(chost, None, context=context, **(x509 or {}))
 69              return self._connection[1]
 70  
 71  ##

it was supposed to be context=self.context. If you hunt upstream you might find a fixup commit which changes that. I notice that on my Fedora box (with latest Python 2.7.x) that line does indeed have context=self.context.

Comment 7 Charalampos Stratakis 2017-10-17 09:14:43 UTC
Good catch. The exact next commit after the initial patch is :

https://github.com/python/cpython/commit/ee44314f9309b7b89dd5a7d897f0f917e9e47b1a#diff-1abc359a7923ab5abc19d0ccde812440

Comment 11 errata-xmlrpc 2018-04-10 15:00:08 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://access.redhat.com/errata/RHBA-2018:0833


Note You need to log in before you can comment on or make changes to this bug.