Beispiel #1
0
    def get_cert(self, context, cert_ref, resource_ref=None, check_only=False,
                 service_name=None):
        """Retrieves the specified cert and registers as a consumer.

        :param context: Oslo context of the request
        :param cert_ref: the UUID of the cert to retrieve
        :param resource_ref: Full HATEOAS reference to the consuming resource
        :param check_only: Read Certificate data without registering
        :param service_name: Friendly name for the consuming service

        :return: octavia.certificates.common.Cert representation of the
                 certificate data
        :raises Exception: if certificate retrieval fails
        """
        connection = self.auth.get_barbican_client(context.project_id)

        LOG.info('Loading certificate secret %s from Barbican.', cert_ref)
        try:
            cert_secret = connection.secrets.get(secret_ref=cert_ref)
            return pkcs12.PKCS12Cert(cert_secret.payload)
        except exceptions.UnreadablePKCS12:
            raise
        except Exception:
            # If our get fails, try with the legacy driver.
            # TODO(rm_work): Remove this code when the deprecation cycle for
            # the legacy driver is complete.
            legacy_mgr = barbican_legacy.BarbicanCertManager()
            legacy_cert = legacy_mgr.get_cert(
                context, cert_ref, resource_ref=resource_ref,
                check_only=check_only, service_name=service_name
            )
            return legacy_cert
Beispiel #2
0
 def get_cert(self,
              context,
              cert_ref,
              resource_ref=None,
              check_only=False,
              service_name=None):
     certbag = self.manager.get(context, cert_ref)
     certbag_data = certbag.get_encoded()
     cert = pkcs12.PKCS12Cert(certbag_data)
     return cert