mirror of
				https://github.com/laurivosandi/certidude
				synced 2025-10-31 01:19:11 +00:00 
			
		
		
		
	Use unicode literals for logging
This commit is contained in:
		| @@ -31,7 +31,7 @@ class CertificateStatusResource(object): | ||||
|  | ||||
| class CertificateAuthorityResource(object): | ||||
|     def on_get(self, req, resp): | ||||
|         logger.info("Served CA certificate to %s", req.context.get("remote_addr")) | ||||
|         logger.info(u"Served CA certificate to %s", req.context.get("remote_addr")) | ||||
|         resp.stream = open(config.AUTHORITY_CERTIFICATE_PATH, "rb") | ||||
|         resp.append_header("Content-Type", "application/x-x509-ca-cert") | ||||
|         resp.append_header("Content-Disposition", "attachment; filename=%s.crt" % | ||||
| @@ -104,7 +104,7 @@ class BundleResource(object): | ||||
|     @login_required | ||||
|     def on_get(self, req, resp): | ||||
|         common_name = req.context["user"].mail | ||||
|         logger.info("Signing bundle %s for %s", common_name, req.context.get("user")) | ||||
|         logger.info(u"Signing bundle %s for %s", common_name, req.context.get("user")) | ||||
|         resp.set_header("Content-Type", "application/x-pkcs12") | ||||
|         resp.set_header("Content-Disposition", "attachment; filename=%s.p12" % common_name.encode("ascii")) | ||||
|         resp.body, cert = authority.generate_pkcs12_bundle(common_name, | ||||
|   | ||||
| @@ -32,7 +32,7 @@ class RequestListResource(object): | ||||
|         csr = Request(body) | ||||
|  | ||||
|         if not csr.common_name: | ||||
|             logger.warning("Rejected signing request without common name from %s", | ||||
|             logger.warning(u"Rejected signing request without common name from %s", | ||||
|                 req.context.get("remote_addr")) | ||||
|             raise falcon.HTTPBadRequest( | ||||
|                 "Bad request", | ||||
| @@ -71,7 +71,7 @@ class RequestListResource(object): | ||||
|             pass | ||||
|         except errors.DuplicateCommonNameError: | ||||
|             # TODO: Certificate renewal | ||||
|             logger.warning("Rejected signing request with overlapping common name from %s", | ||||
|             logger.warning(u"Rejected signing request with overlapping common name from %s", | ||||
|                 req.context.get("remote_addr")) | ||||
|             raise falcon.HTTPConflict( | ||||
|                 "CSR with such CN already exists", | ||||
| @@ -86,11 +86,11 @@ class RequestListResource(object): | ||||
|             click.echo("Redirecting to: %s"  % url) | ||||
|             resp.status = falcon.HTTP_SEE_OTHER | ||||
|             resp.set_header("Location", url.encode("ascii")) | ||||
|             logger.debug("Redirecting signing request from %s to %s", req.context.get("remote_addr"), url) | ||||
|             logger.debug(u"Redirecting signing request from %s to %s", req.context.get("remote_addr"), url) | ||||
|         else: | ||||
|             # Request was accepted, but not processed | ||||
|             resp.status = falcon.HTTP_202 | ||||
|             logger.info("Signing request from %s stored", req.context.get("remote_addr")) | ||||
|             logger.info(u"Signing request from %s stored", req.context.get("remote_addr")) | ||||
|  | ||||
|  | ||||
| class RequestDetailResource(object): | ||||
| @@ -100,7 +100,7 @@ class RequestDetailResource(object): | ||||
|         Fetch certificate signing request as PEM | ||||
|         """ | ||||
|         csr = authority.get_request(cn) | ||||
|         logger.debug("Signing request %s was downloaded by %s", | ||||
|         logger.debug(u"Signing request %s was downloaded by %s", | ||||
|             csr.common_name, req.context.get("remote_addr")) | ||||
|         return csr | ||||
|  | ||||
| @@ -118,7 +118,7 @@ class RequestDetailResource(object): | ||||
|         resp.body = "Certificate successfully signed" | ||||
|         resp.status = falcon.HTTP_201 | ||||
|         resp.location = os.path.join(req.relative_uri, "..", "..", "signed", cn) | ||||
|         logger.info("Signing request %s signed by %s from %s", csr.common_name, | ||||
|         logger.info(u"Signing request %s signed by %s from %s", csr.common_name, | ||||
|             req.context.get("user"), req.context.get("remote_addr")) | ||||
|  | ||||
|  | ||||
| @@ -131,6 +131,6 @@ class RequestDetailResource(object): | ||||
|             # Logging implemented in the function above | ||||
|         except EnvironmentError as e: | ||||
|             resp.body = "No certificate CN=%s found" % cn | ||||
|             logger.warning("User %s failed to delete signing request %s from %s, reason: %s", | ||||
|             logger.warning(u"User %s failed to delete signing request %s from %s, reason: %s", | ||||
|                 req.context["user"], cn, req.context.get("remote_addr"), e) | ||||
|             raise falcon.HTTPNotFound() | ||||
|   | ||||
| @@ -6,7 +6,7 @@ logger = logging.getLogger("api") | ||||
|  | ||||
| class RevocationListResource(object): | ||||
|     def on_get(self, req, resp): | ||||
|         logger.debug("Revocation list requested by %s", req.context.get("remote_addr")) | ||||
|         logger.debug(u"Revocation list requested by %s", req.context.get("remote_addr")) | ||||
|         resp.set_header("Content-Type", "application/x-pkcs7-crl") | ||||
|         resp.append_header("Content-Disposition", "attachment; filename=ca.crl") | ||||
|         resp.body = export_crl() | ||||
|   | ||||
| @@ -26,7 +26,7 @@ class TagResource(RelationalMixin): | ||||
|         args = req.get_param("cn"), req.get_param("key"), req.get_param("value") | ||||
|         rowid = self.sql_execute("tag_insert.sql", *args) | ||||
|         push.publish("tag-added", str(rowid)) | ||||
|         logger.debug("Tag cn=%s, key=%s, value=%s added" % args) | ||||
|         logger.debug(u"Tag cn=%s, key=%s, value=%s added" % args) | ||||
|  | ||||
|  | ||||
| class TagDetailResource(RelationalMixin): | ||||
| @@ -60,7 +60,7 @@ class TagDetailResource(RelationalMixin): | ||||
|         from certidude import push | ||||
|         args = req.get_param("value"), identifier | ||||
|         self.sql_execute("tag_update.sql", *args) | ||||
|         logger.debug("Tag %s updated, value set to %s", | ||||
|         logger.debug(u"Tag %s updated, value set to %s", | ||||
|             identifier, req.get_param("value")) | ||||
|         push.publish("tag-updated", identifier) | ||||
|  | ||||
| @@ -73,4 +73,4 @@ class TagDetailResource(RelationalMixin): | ||||
|         from certidude import push | ||||
|         self.sql_execute("tag_delete.sql", identifier) | ||||
|         push.publish("tag-removed", identifier) | ||||
|         logger.debug("Tag %s removed" % identifier) | ||||
|         logger.debug(u"Tag %s removed" % identifier) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user