Certificate issue when upgrading server from 2.6 to 3.2.1


I’m upgrading our self-hosted server from 2.6.x to 3.2.1. I believe we’re running into issues due to changes in how the certificates/private keys are generated.

If I use the keygen script to generate a brand new set of keys, everything works fine i.e. the website loads and I can see our existing artifacts, deployments, etc, but the server keys are now different than the ones stored on the devices. If I try to copy our old keys, mender-deployments keeps restarting and I get the following error:

RequestError: send request failed mender-deployments_1 | caused by: Put "https://my-mender-url/mender-artifact-storage": EOF

I suspect the problem is because instead of having separate api-gateway and storage-proxy certs/keys, you now just have one certificate and key. I’ve tried concatenating the existing api-gateway and storage-proxy certs and private key into a single cert.crt and private.key file, but that hasn’t worked.

How can we migrate our old style keys to be compatible with the new layout?

I think the problem is due to the fact that the single certificate/key that is currently used now has a subject alternative name that includes a wildcard (e.g. *.mycomain.com). Presumably, some of the services have been changed to point to a subdomain.

If this is true, it sounds like a pretty breaking change - up until version 3.0.2 the keygen script generated separate keys for the storage-proxy and api-gateway which pointed to a fixed domain. In 3.1.0, this changed and only one key was generated that had a wildcard domain. The problem with this is that it seems that the services are now actually using the subdomain and so existing certificates cannot be used in place of this single certificate.

Hope the Mender team can shed light on this.

Are you using self signed certificate for server in LAN production? if you are I would recommend also generating your own self signed CA cert and create your server certificates signed by the CA cert. then you only need to install the public part of your CA cert on your devices. Then you are free to create/update your server cert as needed over time as long as it’s signed by the same CA cert.

If your not using self-signed and using a 3rd party Certificate Authority, and you OS doesnt already have the CA cert and its intermediates certs (if any), then add them to your devices rather than the server cert itself for the same reasons as above.

One thing that has to be noted is that Mender needs the certificate to have filled the DNS part of Alternative Names in the certificate that is stored in the traefik container.

You can see this using the following command.

openssl x509 -in CERTIFICATE -text

Look at the DNS part in the example below.

        Version: 3 (0x2)
        Serial Number:
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: CN = #YOUR DOMAIN NAME
            Not Before: Mar 25 10:18:16 2022 GMT
            Not After : Mar 22 10:18:16 2032 GMT
        Subject: CN = #YOUR DOMAIN NAME
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                RSA Public-Key: (2048 bit)
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
            X509v3 Authority Key Identifier: 

            X509v3 Basic Constraints: critical
            X509v3 Extended Key Usage: 
                TLS Web Server Authentication
            X509v3 Subject Alternative Name: 

The second DNS (your domain with a “*.” before is important.

1 Like

I think this is related Is key rotation made mandatory by 3.1 update?

1 Like

Thanks for the reply. However, the questions remains is that is there a direct upgrade path to 3.2.1? From what I can tell it looks like there isn’t and it is necessary to update the devices to change the certificates before the server is upgraded to 3.2.1, after which the server upgrade can take place.

I wanted to confirm that this was indeed the case. If so, I think it would be necessary to update the Mender documentation, because this is potentially a pretty breaking upgrade.

Are you using self-signed certificates?

We are, yes.

I’m afraid I cannot think of a workaround, because pinning the device to a specific server certificate is normally reserved for non-production setups or ones where it’s easy to change them. For production, you would normally add the CA cert (self-signed CA cert or 3rd party if not already in ca-certificates package) to the device so that you can rotate your server certificates as they are signed by the same CA cert. You can almost certainly achieve pinning by providing your server public CA.cert to mender client instead, or the actual server certificate.

I appreciate having gone back and re-read the Mender docs, this could be clearer.

Caveat: my knowledge of mender is quite old now, and we use our own written client to interact with our mender server, so I’m recalling from memory. However, the principle of certificate management should be the same whether it’s mender software or other TLS client/server setups you may have.

Maybe others with more recent knowledge of mender than I may be able to think of a workaround.