Learn Courses My Dashboard

How to set tlsConfiguration to var?

Hi all, I’m following the mini series by Mikaela, this series is great btw, but now I am having trouble with this error message ‘Cannot assign to property: ‘tlsConfiguration’ is a ‘let’ constant’

The only difference between the tutorial and what I’m doing is switching Postgress for MySql. I’ve been able to find fixes and alternative methods so far but now I’m stuck here.

if let urlString = Environment.get("CLEARDB_DATABASE_URL"),
   var mysqlConfig = MySQLConfiguration(url:urlString){
    var tlsConfig = TLSConfiguration.makeClientConfiguration()
    tlsConfig.certificateVerification = .none
    // Error is on line below
    mysqlConfig.tlsConfiguration = tlsConfig
    app.databases.use(.mysql(configuration: mysqlConfig), as: .mysql)


Here is that code snippet from around the 24:13 mark of Mikaelas tutorial

(Any help is appreciated)

Look at the Vapor docs!

In the MySQL section, the tlsConfig is created in a different way

ty @mikaelacaron I’ll try this out and post an update.

1 Like

Please do! It may help someone else who’s working on a different database than the tutorial series

Copied straight from Vapor docs and it worked, thanks @mikaelacaron (also ty so much for the tutorial in the first place)

1 Like