Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor into class. #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Refactor into class. #8

wants to merge 5 commits into from

Conversation

Ryanb58
Copy link
Contributor

@Ryanb58 Ryanb58 commented Jan 10, 2018

No description provided.

@Ryanb58 Ryanb58 added the WIP label Jan 10, 2018
@btimby
Copy link

btimby commented Jan 11, 2018

@Ryanb58 Wow, this looks excellent Taylor!

),
critical=True
)
cert = cert.sign(key, hashes.SHA256(), default_backend())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signing the certificate with it's own key should probably be an option (self_sign=True) since it is not always desirable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I made the proper modifications to meet this need. LMK what you think of my implementation.

main.py Outdated
'org',
'org_name',
'common'
])
Copy link

@btimby btimby Jan 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two places that you transfer these attributes to x509.NameAttribute instances. You can make that a method on this class. You can actually inherit from a namedtuple class, and add properties / methods to it, like this:

class CertAttributes(namedtuple(...)):
    def to_x509(self):
        pass

main.py Outdated
LOGGER.debug('Writing PEM encoded CSR to %s', fobj.name)
fobj.write(csr.public_bytes(serialization.Encoding.PEM))
fobj.write(b'\n')

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these save functions should probably assert that the format parameter is 'pem' and raise otherwise, like:

if format != 'pem':
    raise NotImplementedError('%s format unsupported, use pem' % format)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants