Add a page detailing the certificate plugin, including classes and the interaction of plugin methods with barbican 'core' logic. Change-Id: Iade34e4b021fe12afb7e4eeba107327cbb70e43f
9.2 KiB
barbican.plugin.interface.certificate_manager
Certificate Plugin Development
This guide describes how to develop a custom certificate plugin for use by Barbican.
Barbican core orchestrates generating SSL certificates, delegating to certificate plugins any required actions. Certificate actions include initiating a certificate order, checking for order updates, and retrieving generated certificates. Barbican plans to include the following certificate plugins:
- A Red Hat Dogtag certificate authority (CA) plugin capable of generating certificates once the order is initiated.
- A Symantec plugin able to interact with the Symantec CA service, requiring periodic status updates to see if certificates are ready.
- A DigiCert plugin able to interact with the DigiCert CA service, with a similar interactions as with Symantec.
certificate_manager
Module
The barbican.plugin.interface.certificate_manager module
contains the classes needed to implement a custom plugin. These classes
include the CertificatePluginBase abstract base class which
custom plugins should inherit from, as well as any Data Transfer Object
(DTO) classes used to pass information into and from plugin methods.
Data Transfer Objects
The DTO classes are used to wrap data that is passed from Barbican to the plugin as well as data that is returned from the plugin back to Barbican. They provide a level of isolation between the plugins and Barbican's internal data models.
ResultDTO
Certificate Status Class
When certificate plugin methods are invoked, they return a
ResultDTO that includes one of the status response
constants defined by the CertificateStatus class. As
detailed in the plugin-certificate-sequence-label section below
Barbican core directs follow on processing for a certificate order based
on these returned status constants.
CertificateStatus
Certificate Parameter Objects
Two dictionaries are available to most certificate plugin methods:
order_meta- A dictionary of values provided by the client when they initiated the Barbican certificate order, including information needed to create a certificate, such as CSR.plugin_meta- A dictionary of values determined by the plugin itself on behalf of a specific certificate order. Barbican core persists this dictionary into the Barbican data store for a given order, and then provides this data back plugin method invocations thereafter.Plugins are free to update this data as required, or else ignore to it if not required. For example, plugins that interact with remote CAs could store the CA's unique order ID, for use with future interactions with that CA.
Plugin Base Class
Barbican secret store plugins should implement the abstract base
class CertificatePluginBase. Concrete plugin
implementations of CertificatePluginBase should be exposed
to Barbican using stevedore mechanisms explained in the
configuration portion of this guide.
CertificatePluginBase
Barbican Order's Status Versus ResultDTO's Status
When Barbican starts processing orders, it sets the order's
status attribute to PENDING. Barbican will
invoke methods on the certificate plugin to process the order, and most
of those methods return a ResultDTO result object, which
also has a status field. Barbican core uses the result's
status to determine follow on processing for the order as
detailed in plugin-certificate-sequence-label below.
The result's status field should be set to one of the
constants defined in CertificateStatus, per plugin-certificate-status-label above. If the result's
status calls for terminating the order, Barbican core will
set the order's status to either ACTIVE or
ERROR. Otherwise the order's status will stay
PENDING, and the order's sub_status and
sub_status_message will be updated with the result's
status and status_message respectively.
Clients that wish to track the progress of potentially long running
certificate orders can poll the order, using the sub_status
and sub_status_message to track the results. Hence plugins
should provide a meaningful message for sub_status_message,
especially on error conditions.
Barbican Core Plugin Sequence
The sequence that Barbican invokes methods on
CertificatePluginBase is detailed next. Note that these
methods are invoked via the
barbican.tasks.certificate_resources module, which in turn
is invoked via Barbican's Worker processes.
Barbican core calls the following methods:
supports()- Asks the plugin if it can support generating a certificate based on the Barbican order'sorder_meta.issue_certificate_request()- Asks the plugin to initiate a certificate order from the providedorder_metaparameter information. An empty dictionary is passed in for theplugin_metaparameter, which the plugin can update as it sees fit. Barbican core will persist and then provide theplugin_metafor subsequent method calls for this order.The plugin method returns a
ResultDTOinstance which Barbican core uses to determine subsequent order processing based on itsstatusfield. Thisstatusfield should be set to one of the constants defined inCertificateStatusperplugin-certificate-status-labelabove.If
statusisCertificateStatus.WAITING_FOR_CAthen Barbican core will invoke thecheck_certificate_statusmethod after the delay specified in the result'sretry_msecfield.If
statusisCertificateStatus.CERTIFICATE_GENERATEDthen Barbican core expects that this order is completed and sets itsstatustoACTIVE. Barbican also expects that the result'scertificateand (optionally)intermediatesfields are filled out with PEM-formatted SSL certificate data. Barbican will then create abarbican.model.models.Containerrecord withbarbican.model.models.Secretrecords to hold the certificate data.If
statusisCertificateStatus.CA_UNAVAILABLE_FOR_REQUESTthen Barbican core will invoke the same method after the delay specified in the result'sretry_msecfield. This condition typically means that a remote CA was not available, so should be retried in the future.If
statusis set toCertificateStatus.CLIENT_DATA_ISSUE_SEENthen Barbican considers the order to have problems with the client-provided data, but otherwise the order is viable. Barbican will keep the order in thePENDINGstate, and update the order'ssub_statustoCertificateStatus.CLIENT_DATA_ISSUE_SEENandsub_status_messageto the result'sstatus_message.Note that client data issues can include missing or incorrect information that the CA reports on. The CA still considers the order open, but clients must provide updates to correct the data. Since the client could either update this order via Barbican, or else work directly with a remote CA, Barbican will invoke the
check_certificate_statusmethod after the delay specified in the result'sretry_msecfield.If
statusis set toCertificateStatus.REQUEST_CANCELEDthen Barbican core expects that this order is completed and sets itsstatustoACTIVE. It also updates the order'ssub_statusandsub_status_messageto the result's status information. This condition could arise (for example) if a remote CA indicated that the certificate order is cancelled.If
statusis set toCertificateStatus.INVALID_OPERATION(or else the plugin raises an exception) then Barbican core considers this a failed order and sets the order'sstatustoERROR. It also updates the order'ssub_statusandsub_status_messageto the result's status information.check_certificate_status()- This method is called as needed after theissue_certificate_request()method and is intended to allow plugins to check to see if a certificate has been issued yet.The result's
statusis processed similarly to theissue_certificate_request()method.modify_certificate_request- This method is invoked if clients provide updates to the order metadata after the certificate order has been initiated.The result's
statusis processed similarly to theissue_certificate_request()method.cancel_certificate_request- This method is invoked if clients delete or cancel a certificate order.Note that if a remote CA is involved the cancellation may not be processed immediately, in which case Barbican core will invoke the
check_certificate_statusmethod after the delay specified in the result'sretry_msecfield. Otherwise the result'sstatusis processed similarly to theissue_certificate_request()method.