From 9fc2cab972c3506b96d49b8d341259360b486eb1 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Aug 02 2017 14:15:13 +0000 Subject: certs: write and read bytes as such There were several cases in ipaserver.install.certs where bytes would be read/written as normal strings, this commit fixes that. https://pagure.io/freeipa/issue/4985 Reviewed-By: Felipe Volpone --- diff --git a/ipaserver/install/certs.py b/ipaserver/install/certs.py index 210e7d2..1b9085e 100644 --- a/ipaserver/install/certs.py +++ b/ipaserver/install/certs.py @@ -380,7 +380,7 @@ class CertDB(object): self.issue_server_cert(self.certreq_fname, self.certder_fname) self.import_cert(self.certder_fname, nickname) - with open(self.certder_fname, "r") as f: + with open(self.certder_fname, "rb") as f: dercert = f.read() return x509.load_der_x509_certificate(dercert) finally: @@ -459,7 +459,7 @@ class CertDB(object): # Write the certificate to a file. It will be imported in a later # step. This file will be read later to be imported. - with open(cert_fname, "w") as f: + with open(cert_fname, "wb") as f: f.write(cert) def issue_signing_cert(self, certreq_fname, cert_fname): @@ -503,7 +503,7 @@ class CertDB(object): # Write the certificate to a file. It will be imported in a later # step. This file will be read later to be imported. - with open(cert_fname, "w") as f: + with open(cert_fname, "wb") as f: f.write(cert) def add_cert(self, cert, nick, flags):