Search code examples
servicestackormlite-servicestack

ServiceStack.OrmLite 5.1.1: "host... does not support SSL connections"


I upgraded to version 5.1.1 of ServiceStack OrmLite (via MyGet), and when I try to open a connection to the db, I suddenly get this error:

MySql.Data.MySqlClient.MySqlException: 'The host 127.0.0.1 does not support SSL connections.'

Before the upgrade I was running v 5.1.0, and I got no such error.

I initialize OrmLite as follows:

private void InitOrmLite()
{
    JsConfig.IncludeTypeInfo = true;
    OrmLiteConfig.ThrowOnError = JsConfig.ThrowOnError = true;
    //OrmLiteConfig.BeforeExecFilter = dbCmd => Console.WriteLine(dbCmd.GetDebugString());
    _dbFactory = new OrmLiteConnectionFactory($"Uid={dbUsername};Password={dbPassword};Server={dbAddress};Port={dbPort};Database={dbDatabase}", MySqlDialect.Provider);
    SetTableMeta();
}

and usage is

using (var _db = dbFactory.Open())
{
    // AlterTable will create if not exist, otherwise add columns that was added to the PCO 
    _db.AlterTable<Customer>(MySqlDialect.Provider);
}

And here it is:

enter image description here

There is a workaround, that I am posting as an answer, but I'd like mythz input on this =)


Solution

  • The workaround that I found, is to add the following to the connection string:

    SslMode=None

    so, the connectionstring would be:

    $"Uid={dbUsername};Password={dbPassword};Server={dbAddress};Port={dbPort};Database={dbDatabase};SslMode=None", MySqlDialect.Provider

    When doing so, the exception is gone.