def get_certificate(context, signature_certificate_uuid):
 keymgr_api = key_manager.API()
 try:
  cert = keymgr_api.get(context, signature_certificate_uuid)
 except KeyManagerError as e:
  msg = (_LE('Unable to retrieve certificate with ID %(id)s: %(e)s') % {'id': signature_certificate_uuid, 'e': encodeutils.exception_to_unicode(e)})
  LOG.error(msg)
  raise exception.SignatureVerificationError(reason=(_('Unable to retrieve certificate with ID: %s') % signature_certificate_uuid))
 if (cert.format not in CERTIFICATE_FORMATS):
  raise exception.SignatureVerificationError(reason=(_('Invalid certificate format: %s') % cert.format))
 if (cert.format == X_509):
  cert_data = cert.get_encoded()
  certificate = x509.load_der_x509_certificate(cert_data, default_backend())
 verify_certificate(certificate)
 return certificate

def get_certificate ( context , signature_certificate_uuid ) : keymgr_api = key_manager . API ( ) try : cert = keymgr_api . get ( context , signature_certificate_uuid ) except KeyManagerError as e : msg = ( _LE ( 'Unable to retrieve certificate with ID %(id)s: %(e)s' ) % { 'id' : signature_certificate_uuid , 'e' : encodeutils . exception_to_unicode ( e ) } ) LOG . error ( msg ) raise exception . SignatureVerificationError ( reason = ( _ ( 'Unable to retrieve certificate with ID: %s' ) % signature_certificate_uuid ) ) if ( cert . format not in CERTIFICATE_FORMATS ) : raise exception . SignatureVerificationError ( reason = ( _ ( 'Invalid certificate format: %s' ) % cert . format ) ) if ( cert . format == X_509 ) : cert_data = cert . get_encoded ( ) certificate = x509 . load_der_x509_certificate ( cert_data , default_backend ( ) ) verify_certificate ( certificate ) return certificate
create the certificate object from the retrieved certificate data .