private X509Certificate2 CheckDefaultCertificate() { using var db = new LiteDbConfigurationRepository(); var webSslCert = db.WebSslCertificate; if (webSslCert != null) { return(webSslCert); } webSslCert = CertificateHelper.CreateDefaultSslCertificate(); db.WebSslCertificate = webSslCert; Log.Logger.Information("Created and installed a default web ssl certificate."); // Need to make sure that we return a db instance of the certificate rather than a local instance // So rather than just returning the webSslCert created above, get a new instance of the certificate // from the database. return(db.WebSslCertificate); }