openssl cms error does not raise an exception or log the problem

Bug #1112784 reported by Dan Nguyen
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-keystoneclient
Won't Fix
High
Unassigned

Bug Description

Desc
-------
This was discovered while trying to run reddwarf locally on a mac pointed to a remote devstack instance.
The root of the problem is that Mac OS X comes installed with openssl but it does not have cms enabled.
It was not clear where the problem came from due to the "Revoked Token" error that was thrown.

Offending code
----------------------
keystoneclient/common/cms.py

...

def cms_verify(formatted, signing_cert_file_name, ca_file_name):
    """
        verifies the signature of the contents IAW CMS syntax
    """
    _ensure_subprocess()
    process = subprocess.Popen(["openssl", "cms", "-verify",
                                "-certfile", signing_cert_file_name,
                                "-CAfile", ca_file_name,
                                "-inform", "PEM",
                                "-nosmimecap", "-nodetach",
                                "-nocerts", "-noattr"],
                               stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    output, err = process.communicate(formatted)
    retcode = process.poll()
    if retcode:
        LOG.error('Verify error: %s' % err)
        raise subprocess.CalledProcessError(retcode, "openssl", output=err)
    return output

...

When 'cms' is not enabled an err is returned from the 'process.communicate(formatted)' call.
The code above only checks for the retcode which is 0 and empty string is returned as output.
This eventually leads to an InValid Token exception.

Proposed fix:
------------------
Log the err so that it's more clear what the actual problem is.
Perhaps on debug or info level.

It appears that the returned value for error can be a successful validation.

description: updated
summary: - openssl cms error does not raise and exception or logged
+ openssl cms error does not raise an exception or log the problem
description: updated
description: updated
Revision history for this message
Dan Nguyen (daniel-a-nguyen) wrote :

Should also document the requirement for openssl with cms support as well.

description: updated
Revision history for this message
Adam Young (ayoung) wrote :

Please docuemnt what you mean by "not enabled." I assume you mean "not installed"
Ensuring the cms is available is a package level process. Devstack does this, as do the various distro packages for keystoneclient.

If this is not the case, please add what the error is that you are seeing.

Changed in python-keystoneclient:
status: New → Incomplete
status: Incomplete → Fix Committed
status: Fix Committed → Incomplete
Dolph Mathews (dolph)
Changed in python-keystoneclient:
importance: Undecided → High
Revision history for this message
Dolph Mathews (dolph) wrote :

I don't think this is incomplete. "CalledProcessError: Command 'openssl' returned non-zero exit status 2" is completely useless feedback as demonstrated in bug 1217734.

Changed in python-keystoneclient:
status: Incomplete → Triaged
Adam Young (ayoung)
Changed in python-keystoneclient:
assignee: nobody → Adam Young (ayoung)
Revision history for this message
Dolph Mathews (dolph) wrote :
Revision history for this message
Dolph Mathews (dolph) wrote :

Any progress on this?

Revision history for this message
Steve McLellan (sjmc7) wrote :

This just bit someone on my team, too - better error handling would be helpful.

Revision history for this message
Dolph Mathews (dolph) wrote :

Unassigned due to inactivity.

Changed in python-keystoneclient:
assignee: Adam Young (ayoung) → nobody
Revision history for this message
Steve Martinelli (stevemar) wrote :

i'm marking this as won't fix for two reasons:

 1) it looks like adam added some extra exception handling, which will likely provide the desired raised exception, see patch in [0]
 2) we are no longer pursuing any work for improving PKI token formats as of Mitaka.

[0] https://github.com/openstack/python-keystoneclient/blob/master/keystoneclient/common/cms.py#L188-L195

Changed in python-keystoneclient:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.