Comment 7 for bug 2033066

Revision history for this message
Tom Haddon (mthaddon) wrote :

Ok, I've been able to reproduce the issue with the following bundle:
```
# Create certs as follows:
# openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname"
#
applications:
  haproxy:
    charm: haproxy
    num_units: 1
    series: jammy
    options:
      default_timeouts: queue 60000, connect 5000, client 120000, server 120000
      global_default_bind_options: no-tlsv10
      services: ''
      ssl_cert: include-base64://cert.pem
      ssl_key: include-base64://key.pem
  landscape-server:
    charm: landscape-server
    series: bionic
    num_units: 1
    options:
      ssl-cert: include-base64://cert.pem
      ssl-key: include-base64://key.pem
  postgresql:
    charm: postgresql
    channel: latest/stable
    series: jammy
    num_units: 1
relations:
  - - haproxy
    - landscape-server
  - - landscape-server:db
    - postgresql:db-admin
```
I've got a fix (not the one I was proposing), but am running into another problem, which I think is related to the version of HAProxy I'm using. I'll test again tomorrow with the same series as in the bundle above to confirm.

The fix I think will be:
```
$ bzr di
=== modified file 'hooks/hooks.py'
--- old/hooks/hooks.py 2023-08-09 07:20:52 +0000
+++ new/hooks/hooks.py 2023-08-29 16:30:45 +0000
@@ -832,7 +832,7 @@
             path = get_service_lib_path(service_name)
             full_path = os.path.join(
                 path, "%s.http" % errorfile["http_status"])
- with open(full_path, 'w') as f:
+ with open(full_path, 'wb') as f:
                 f.write(base64.b64decode(errorfile["content"]))

         # Write to disk the content of the given SSL certificates

```