Metabase Suddenly Unable to Read Public RSA Key

We had a connection to a database which Metabase was suddenly unable to connect to.

We have a Public RSA Key stored on Azure. However Metabase can no longer read the file. Despite the fact that I can easily access the file. It is throwing this error.

Could not read server RSA public key from file :

There should be no permission issues preventing this file from being read.

Metabase Version: 0.35.3

Hi @nick-sbp
Please post “Diagnostic Info” from Admin > Troubleshooting.
I guess that something must have changed, since Metabase wouldn’t stop working suddenly.
There should be a more detailed error than what you posted in the log.
Also, latest release is 0.37.7

This is the only error I can find in the logs, aside from it being blocked from too many connection errors and clearing that issue. I’ve obscured the link to my public key and the path to my key in the output.

[fbbff05e-beb2-46ac-ad71-2f454da996e4] 2021-01-24T13:41:29-05:00 ERROR metabase.driver.util Database connection error
[fbbff05e-beb2-46ac-ad71-2f454da996e4] 2021-01-24T13:41:29-05:00 ERROR metabase.api.database Cannot connect to Database
[fbbff05e-beb2-46ac-ad71-2f454da996e4] 2021-01-24T13:41:29-05:00 DEBUG metabase.middleware.log PUT /api/database/10 400 448.9 ms (1 DB calls)
{:valid false,
:dbname
"Could not connect to address=(host={{ip}})(port=3306)(type=master) : Could not read server RSA public key from file : serverRsaPublicKeyFile={{valid path to key file}}",
:message
"Could not connect to address=(host={{ip}})(port=3306)(type=master) : Could not read server RSA public key from file : serverRsaPublicKeyFile={{valid path to key file}}"}

@nick-sbp I guess something was changed on the Azure - probably the login method - you would need to change that, see the comments for workarounds:
https://github.com/metabase/metabase/issues/12545

@flamber We’ve tried moving the key to other hosts than Azure. It doesn’t seem to be able to read a file from anywhere, even when completely publicly accessible.

@nick-sbp
I don’t see how Metabase would stop working suddenly without something being changed somewhere - I would recommend that you revert to backups in that case.
Post “Diagnostic Info” from Admin > Troubleshooting.
You would have to set serverRsaPublicKeyFile=/path/to/your/rsa.key in your connection string in Admin > Databases.

It is in the connection string under ‘Additional JDBC connection string options’ as ‘serverRsaPublicKeyFile=https://example-site.com/rsa_pub’

Diagnostic Info:

{
  "browser-info": {
    "language": "en-US",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4385.0 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.5+10",
    "java.vendor": "AdoptOpenJDK",
    "java.vendor.url": "https://adoptopenjdk.net/",
    "java.version": "11.0.5",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.5+10",
    "os.name": "Linux",
    "os.version": "4.14.198-152.320.amzn2.x86_64",
    "user.language": "en",
    "user.timezone": "UTC"
  },
  "metabase-info": {
    "databases": [
      "mysql",
      "sqlserver",
      "h2",
      "postgres"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "10.14"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.8"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2020-04-21",
      "tag": "v0.35.3",
      "branch": "release-0.35.x",
      "hash": "1d424cb"
    },
    "settings": {
      "report-timezone": "Europe/London"
    }
  }
}

@nick-sbp And that address is accessible from the host running Metabase? I don’t know what is going on, but you can try enabling debug/trace logging to see if it will write more details about what is going on:
https://www.metabase.com/docs/latest/operations-guide/log-configuration.html
Metabase does not suddenly stop working, so I guess something else has changed and is causing problems. Latest release is 0.37.7