Skip to content

Can we have a basic example of how to use this? #26

@keefbaker

Description

@keefbaker

The documentation describes how the modules fit together, but not always the required contents to get this to work.

Can we have an example of the creation of a signing request and then a sign so it's easier to work with.

For example I have:


import cfssl.cfssl as cfssl
import cfssl.models as CModel

<redact other class methods>

    def cfssl_connect(self, certdir):
        common_name = self.config.environment + self.domain
        ssl = cfssl.CFSSL(self.pki_server, self.pki_port, verify_cert=False)
        key = CModel.config_key.ConfigKey(algorithm='rsa',
                                          strength=self.openssl_bits)

        host = CModel.host.Host(self.config.environment, common_name)
        certinfo = CModel.subject_info.SubjectInfo(a,
                                                   b,
                                                   c,
                                                   d,
                                                   e)

        certfiles = ssl.new_key((host,), (certinfo,),
                                common_name=common_name,
                                key=key)
        csr = certfiles["certificate_request"]
        key = certfiles["private_key"]
        try:
            print self.pki_key
            print ssl.auth_sign(self.pki_key, csr)
        except Exception as e:
            print str(e)

So I'm creating the appropriate objects, getting the CSR and key back and then when I try to do an auth_sign I get:

illegal base64 data at input byte 0 (400)

However if I try to base64 encode the cert using base64.b64encode() I get:

Unable to parse authenticated sign request (400)

The only reason I've managed to get as far as I have is because I've read the source code. Some help with the above would be great but posting an actual example would be a great move IMO as the documentation just describes methods and not how to use it.

Thanks.

PS: I'm happy to write an example if I can get the above working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions