Package: cert_manager
python-cert_managerThis library provides aPythoninterface to theSectigoCertificate Manager REST API.  python-cert_manager is open sourced under theBSD 3-Clause license.Basicscert_managerruns onPython>= 3.7FeaturesThere are many API endpoints under Certificate Manager, and this library currently supports a subset of those endpoints.  The current list of written and tested endpoint classes includes:Organization (/organization)Person (/person)SSL (/ssl)Client Administrator (/admin)Domain (/domain)Report (/report)Other endpoints we hope to add in the near future:Code Signing Certificates (/csod)Custom Fields (/customField)Domain Control Validation (/dcv)Device Certificates (/device)Discovery (/discovery)SMIME (/smime)InstallingYou can use pip to install cert_manager:pipinstallcert_managerExamplesThis is a simple example that just shows initializing theClientobject and using it to query theOrganizationandSSLendpoints:fromcert_managerimportOrganizationfromcert_managerimportClientfromcert_managerimportSSLclient=Client(base_url="https://cert-manager.com/api",login_uri="SomeOrg",username="your_username",password="your_password",)org=Organization(client=client)ssl=SSL(client=client)print(ssl.types)print(org.all())The most common process you would do, however, is enroll and then collect a certificate you want to order from the Certificate Manager:fromtimeimportsleepfromcert_managerimportOrganizationfromcert_managerimportClientfromcert_managerimportSSLclient=Client(base_url="https://cert-manager.com/api",login_uri="SomeOrg",username="your_username",password="your_password",)# We need to enroll the certificate under an organization, so we will need to query the API for thatorg=Organization(client=client)# We need the SSL module to enroll the certificatessl=SSL(client=client)cert_org=org.find(dept_name="MyDept")withopen("host.csr","r")asfilep:csr=filep.read()result=ssl.enroll(cert_type_name="InCommon SSL (SHA-2)",csr=csr,term=365,org_id=cert_org[0]["id"])# This is just for demonstration purposes.# Doing a wait loop like this to poll for the certificate is not the best way to go about this.while(True):# Collect the certificate from Sectigotry:cert_pem=ssl.collect(cert_id=result["sslId"],cert_format="x509CO")print(cert_pem)breakexceptPendingError:print("Certificate is still pending...sleeping for 60s")sleep(60)continueexceptException:# For some unexpected exception, exitbreakContributingPull requests to add functionality and fix bugs are always welcome.  Please check the CONTRIBUTING.md for specifics on contributions.TestingWe try to have a high level of test coverage on the code.  Therefore, when adding anything to the repo, tests should be written to test a new feature or to test a bug fix so that there won't be a regression.  This library is setup to be pretty simple to build a working development environment usingDocker.  Therefore, it is suggested that you haveDockerinstalled where you clone this repository to make development easier.To start a development environment, you should be able to just run thedev.shscript.  This script will use theDockerfilein this repository to build aDockercontainer with all the dependencies for development installed usingPipenv../dev.shThe first time you run the script, it should build theDockerimage and then drop you into the container's shell.  The directory where you cloned this repository should be volume mounted in to/usr/src, which should also be the current working directory.  From there, you can make changes as you see fit.  Tests can be run from the/usr/srcdirectory by simply typinggreenasgreenhas been setup to with the correct parameters.ChangelogTo generate theCHANGELOG.md, you will needDockerand a GitHub personal access token.  We currently usegithub-changelog-generatorfor this purpose.  The following should generate the file using information from GitHub:dockerrun-it--rm\-eCHANGELOG_GITHUB_TOKEN='yourtokenhere'\-v"$(pwd)":/working\-w/working\ferrarimarco/github-changelog-generator--verboseTo generate the log for an upcoming release that has not yet been tagged, you can run a command to include the upcoming release version.  For example,2.0.0:dockerrun-it--rm\-eCHANGELOG_GITHUB_TOKEN='yourtokenhere'\-v"$(pwd)":/working\-w/working\ferrarimarco/github-changelog-generator--verbose--future-release2.0.0--unreleasedAs a note, this repository uses the default labels for formatting theCHANGELOG.md.  Label information can be found here:Advanced-change-log-generation-examplesReleasesReleases to the codebase are typically done using thebump2versiontool.  This tool takes care of updating the version in all necessary files, updating its own configuration, and making a GitHub commit and tag.  We typically do version bumps as part of a PR, so you don't want to havebump2versiontag the version at the same time it does the commit as commit hashes may change.  Therefore, to bump the version a patch level, one would run the command:bump2version--verbose--no-tagpatchOnce the PR is merged, you can then checkout the newmainbranch and tag it using the new version number that is now in.bumpversion.cfg:gitcheckoutmain
gitpull--rebase
gittag1.0.0-m'Bump version: 0.1.0 → 1.0.0'gitpush--tags