Use bytes instead of str for writing SSL files

Change-Id: I74930cf363fe652a34d7ad86cdc493b15557ed40
Closes-Bug: #1799877
This commit is contained in:
Chris MacNaughton 2018-10-26 12:39:02 +02:00
parent 0d1dec7e0b
commit e41371802f
2 changed files with 4 additions and 4 deletions

View File

@ -248,9 +248,9 @@ class ApacheSSLContext(OSContextGenerator):
ssl_cert, ssl_key = get_cert()
if all([ssl_cert, ssl_key]):
with open('/etc/ssl/certs/dashboard.cert', 'w') as cert_out:
with open('/etc/ssl/certs/dashboard.cert', 'wb') as cert_out:
cert_out.write(b64decode(ssl_cert))
with open('/etc/ssl/private/dashboard.key', 'w') as key_out:
with open('/etc/ssl/private/dashboard.key', 'wb') as key_out:
key_out.write(b64decode(ssl_key))
os.chmod('/etc/ssl/private/dashboard.key', 0o600)
ctxt = {

View File

@ -108,8 +108,8 @@ class TestHorizonContexts(CharmTestCase):
'ssl_cert': '/etc/ssl/certs/dashboard.cert',
'ssl_key': '/etc/ssl/private/dashboard.key'})
_open.assert_has_calls([
call('/etc/ssl/certs/dashboard.cert', 'w'),
call('/etc/ssl/private/dashboard.key', 'w')
call('/etc/ssl/certs/dashboard.cert', 'wb'),
call('/etc/ssl/private/dashboard.key', 'wb')
])
_file.write.assert_has_calls([
call('cert'),