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 <fbarreto@redhat.com>
This commit is contained in:
Stanislav Laznicka 2017-07-28 14:26:24 +02:00 committed by Pavel Vomacka
parent 6f8d90d97a
commit 9fc2cab972

View File

@ -380,7 +380,7 @@ class CertDB(object):
self.issue_server_cert(self.certreq_fname, self.certder_fname) self.issue_server_cert(self.certreq_fname, self.certder_fname)
self.import_cert(self.certder_fname, nickname) 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() dercert = f.read()
return x509.load_der_x509_certificate(dercert) return x509.load_der_x509_certificate(dercert)
finally: finally:
@ -459,7 +459,7 @@ class CertDB(object):
# Write the certificate to a file. It will be imported in a later # Write the certificate to a file. It will be imported in a later
# step. This file will be read later to be imported. # 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) f.write(cert)
def issue_signing_cert(self, certreq_fname, cert_fname): 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 # Write the certificate to a file. It will be imported in a later
# step. This file will be read later to be imported. # 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) f.write(cert)
def add_cert(self, cert, nick, flags): def add_cert(self, cert, nick, flags):