Merge lp://qastaging/~jacekn/charm-helpers/charm-helpers-ssl into lp://qastaging/charm-helpers

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 76
Proposed branch: lp://qastaging/~jacekn/charm-helpers/charm-helpers-ssl
Merge into: lp://qastaging/charm-helpers
Diff against target: 151 lines (+139/-0)
2 files modified
charmhelpers/contrib/ssl/__init__.py (+79/-0)
tests/contrib/ssl/test_ssl.py (+60/-0)
To merge this branch: bzr merge lp://qastaging/~jacekn/charm-helpers/charm-helpers-ssl
Reviewer Review Type Date Requested Status
Matthew Wedgwood (community) Approve
Review via email: mp+182365@code.qastaging.launchpad.net

Description of the change

Added contrib.ssl module which can create selfsigned SSL certificates.

To post a comment you must log in.
Revision history for this message
Matthew Wedgwood (mew) wrote :

This looks quite helpful. Thanks.

I see a few issues here.

Running this as generate_selfsigned("mykey", "mycert") fails:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "charmhelpers/contrib/ssl/__init__.py", line 19, in generate_selfsigned
    subprocess.check_call(cmd)
UnboundLocalError: local variable 'cmd' referenced before assignment

There should be a test that catches this.

Furthermore, the "subject" argument is a little opaque. I somewhat expected to be able to pass it a hostname, but that's not at all what's needed. I'd recommend any combination of:

1. Adding a docstring with a little explanation
2. Exposing the subject components as function args (rather than as one dict)

As a bonus, it might be nice to allow users to specify the number of bits the for the cert as 1024 will inevitably fall out of vogue.
3. Building a simple "CertificateSubject" class to help users construct a valid subject
4. Providing reasonable defaults.

review: Needs Fixing
75. By Jacek Nykis

Added docstring to the generate_selfsigned function. Improved the function to accept single cn argument and partial subject dict

Revision history for this message
Matthew Wedgwood (mew) wrote :

I'm able to get the new function succeed using the "cn" parameter, but it explodes[1] when I try to use "subject." I've tried that one with various permutations on the keys included in the dict. I haven't tested the "config" parameter.

Also, I notice you're returning False for failures, but when the function actually succeeds, it returns None. You might want an explicit "return True" at the end.

[1] http://pastebin.ubuntu.com/6034287/

review: Needs Fixing
76. By Jacek Nykis

Added more error checking to contrib.ssl.generate_selfsigned function

Revision history for this message
Jacek Nykis (jacekn) wrote :

I added more error checking and return True statement.

Your test is failing as expected, country code should be 2 letter code. With my changes this will be picked up by the try/except block I added but there is no way I can return exact reason for openssl command failure.

Revision history for this message
Matthew Wedgwood (mew) wrote :

Ah, that makes sense. With these changes, LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches