Skip to content
This repository was archived by the owner on Jan 18, 2025. It is now read-only.

New crypt function test fails with system python2.6 on OSX #117

Merged
merged 1 commit into from
Feb 6, 2015

Conversation

craigcitro
Copy link
Contributor

/cc @dhermes

i didn't dig too far, but it looks like the system python doesn't behave as expected:

======================================================================
FAIL: test_succeeds (tests.test_crypt.Test_pkcs12_key_as_pem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/craigcitro/gh/oauth2client/tests/test_crypt.py", line 57, in test_succeeds
    self.assertEqual(pem_contents, pkcs12_key_as_pem)
AssertionError: '-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEA4ej0p7bQ7L/r4rVGUz9RN4VQWoej1Bg1mYWIDYslvKrk1gpj\n7wZgkdmM7oVK2OfgrSj/FCTkInKPqaCR0gD7K80q+mLBrN3PUkDrJQZpvRZIff3/\nxmVU1WeruQLFJjnFb2dqu0s/FY/2kWiJtBCakXvXEOb7zfbINuayL+MSsCGSdVYs\nSliS5qQpgyDap+8b5fpXZVJkq92hrcNtbkg7hCYUJczt8n9hcCTJCfUpApvaFQ18\npe+zpyl4+WzkP66I28hniMQyUlA1hBiskT7qiouq0m8IOodhv2fagSZKjOTTU2xk\nSBc//fy3ZpsL7WqgsZS7Q+0VRK8gKfqkxg5OYQIDAQABAoIBAQDGGHzQxGKX+ANk\nnQi53v/c6632dJKYXVJC+PDAz4+bzU800Y+n/bOYsWf/kCp94XcG4Lgsdd0Gx+Zq\nHD9CI1IcqqBRR2AFscsmmX6YzPLTuEKBGMW8twaYy3utlFxElMwoUEsrSWRcCA1y\nnHSDzTt871c7nxCXHxuZ6Nm/XCL7Bg8uidRTSC1sQrQyKgTPhtQdYrPQ4WZ1A4J9\nIisyDYmZodSNZe5P+LTJ6M1SCgH8KH9ZGIxv3diMwzNNpk3kxJc9yCnja4mjiGE2\nYCNusSycU5IhZwVeCTlhQGcNeV/skfg64xkiJE34c2y2ttFbdwBTPixStGaF09nU\nZ422D40BAoGBAPvVyRRsC3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uHV8nroGVKOhd9/Rb5K47Hke4kk\nBrn5a0Ues9qPDF65Fw1ryPDFSwHufjXAAO5SpZZJF51UGDgiNvDedbBgMQKBgHSk\nt7DjPhtW69234eCckD2fQS5ijBV1p2lMQmCygGM0dXiawvN02puOsCqDPoz+fxm2\nDwPY80cw0M0k9UeMnBxHt25JMDrDan/iTbxu++T/jlNrdebOXFlxlI5y3c7fULDS\nLZcNVzTXwhjlt7yp6d0NgzTyJw2ju9BiREfnTiRBAoGBAOPHrTOnPyjO+bVcCPTB\nWGLsbBd77mVPGIuL0XGrvbVYPE8yIcNbZcthd8VXL/38Ygy8SIZh2ZqsrU1b5WFa\nXUMLnGEODSS8x/GmW3i3KeirW5OxBNjfUzEF4XkJP8m41iTdsQEXQf9DdUY7X+CB\nVL5h7N0VstYhGgycuPpcIUQa\n-----END PRIVATE KEY-----\n'

The issue is (likely?) a difference in some crypto dependency, but we should check that things work (or fail appropriately).

@dhermes
Copy link
Contributor

dhermes commented Jan 16, 2015

Did you run via tox or other?

@craigcitro craigcitro changed the title New crypt function fails with system python2.6 on OSX New crypt function test fails with system python2.6 on OSX Jan 16, 2015
@craigcitro
Copy link
Contributor Author

both -- fails in tox and directly using /usr/bin/python2.6.

@dhermes
Copy link
Contributor

dhermes commented Jan 16, 2015

I'm trying to find documentation, but doesn't Apple ship a fake version of openssl or their own custom substitute not even named openssl?

@dhermes
Copy link
Contributor

dhermes commented Jan 16, 2015

On my machines:

$ # Linux
$ openssl version
OpenSSL 1.0.1f 6 Jan 2014

$ # Mac OS X
$ openssl version
OpenSSL 0.9.8za 5 Jun 2014

@dhermes
Copy link
Contributor

dhermes commented Jan 16, 2015

So, regarding googleapis/google-cloud-python#537, I tested with this and it works even though OpenSSL 0.9.8za spits out a different PEM key than OpenSSL 1.0.1f. (Like I actually visited the signed URL, gave an expiration of 60 seconds and I could view the content for the whole 60 seconds on both OSes.)

It still means the tests fails on OS X. Can you get one of your auth contacts to weigh in?

@dhermes
Copy link
Contributor

dhermes commented Jan 22, 2015

More context:

OS X puts stuff in /System/... and then puts /System/... ahead of standard location (i.e. the one pip uses) on the import path.

SRSLY APPLE? Thanks but no thanks.

On the flip-side: Heartbleed never impacted OS X since they use a custom OpenSSL (at C level, not just Python).

@craigcitro
Copy link
Contributor Author

@anthmgoogle Anthony, an auth question for you: we're seeing that some of the auth libraries we use for signing behave slightly differently. what OS/openssl version(s) do we want to support? "as many as possible" is my guess, but want to confirm.

@dhermes same command as you on the machine where it fails:

$ which openssl
/usr/bin/openssl
$ openssl version
OpenSSL 0.9.8zc 15 Oct 2014

maybe za and zc differ in some small way?

@dhermes
Copy link
Contributor

dhermes commented Feb 6, 2015

@craigcitro We still support Mac OS X. The test just fails because the signed content is different so comparing to pem_from_pkcs12.pem fails.

As I mentioned above, using the signed content still works, i.e. it's still valid.

@craigcitro
Copy link
Contributor Author

ah, maybe i misread that above -- should we just loosen the test to check for either key?

@anthmgoogle if everything seems to function properly, do you have any strong feelings from the auth side?

@dhermes
Copy link
Contributor

dhermes commented Feb 6, 2015

Yeah we could just create the equivalent for the openssl that Apple uses and then use that file in the test if sys.platform == 'darwin'.

EDIT: This will cause failures if people ditch Apple's openssl and install the actual one via Homebrew. This would also require removing the version of PyCrypto that is shipped in /System/....

@craigcitro
Copy link
Contributor Author

i was thinking something more lowbrow -- the input is fixed, and we have a small finite number of possible outputs. just check that it's one of them and call it a day?

@dhermes
Copy link
Contributor

dhermes commented Feb 6, 2015

SGTM

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

It turns out that the result may be different depending on openSSL versions;
rather than play games, we just check that we get one of the expected outputs.
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Feb 6, 2015
@craigcitro
Copy link
Contributor Author

PTAL @dhermes

@dhermes
Copy link
Contributor

dhermes commented Feb 6, 2015

Why don't you name _alternate Mac OS X or something? Other than the history, the test gives no indication of why more than one file is needed.

@craigcitro
Copy link
Contributor Author

(test failure is because i cancelled the second run when i pushed to correct author; passing version is here: https://travis-ci.org/google/oauth2client/builds/49809411

as to the filename -- i don't think we're going to encode enough into it to nail down the failing version, so it seems misleading. (for instance, it works for you on OSX -- someone else in the same boat might say "oh maybe we can delete this now".)

@dhermes
Copy link
Contributor

dhermes commented Feb 6, 2015

I was just suggesting a comment as to the origin of the file. Do as you wish.

craigcitro added a commit that referenced this pull request Feb 6, 2015
New crypt function test fails with system python2.6 on OSX
@craigcitro craigcitro merged commit 535388c into googleapis:master Feb 6, 2015
@anthmgoogle
Copy link

No concerns with checking for either key type.

On Fri, Feb 6, 2015 at 3:54 PM, Craig Citro [email protected]
wrote:

Merged #117 #117.


Reply to this email directly or view it on GitHub
#117 (comment).

@craigcitro craigcitro deleted the classy_tests branch February 12, 2015 18:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants