umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.45k stars 2.68k forks source link

Cannot connect to SQL Server during install #14272

Closed idseefeld closed 1 year ago

idseefeld commented 1 year ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

v12 rc

Bug summary

In the install step "Configure your database" I cannot connect to SQL Server 2019 database neither with integrated authentication nor database user account. I use a a named instance "SQL2019":

configure-your-database-install-step

I have verified with SQL Server Management Studio, that connection with this settings is working and user has owner permissions. The project works fine with SQLite.

Specifics

No response

Steps to reproduce

Create a fresh v12 Umbraco project. Run and choose SQL Server instead of SQLite database.

Expected result / actual result

No response


_This item has been added to our backlog AB#29662_

github-actions[bot] commented 1 year ago

Hi there @idseefeld!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

idseefeld commented 1 year ago

I tried Paul Seals "Package Script Writer" and got an error message in the terminal window:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - Die Zertifikatkette wurde von einer nicht vertrauenswürdigen Zertifizierungsstelle ausgestellt.)

So I think the issue is caused by an issue on my machine.

abjerner commented 1 year ago

I'm getting the same issue, so might still be worth looking into.

When googling the error, it could seem that this might be due to a version of SQL server that is no longer supported by the SQL driver that ships with Umbraco 12. In my case, I'm using SQL Express, and can't remember the last time that I updated it, so there could be some truth to that. But I haven't had the time to look into this yet.

idseefeld commented 1 year ago

I'm using a fairly recent SQL Server 2019 developer edition. And I have tried the same database with an Umbraco version 10.5.1 without any issues. So, I guess this need to be investigated.

abjerner commented 1 year ago

I can see I'm not 12.0.2569.0, which should be SQL Server 2014. So I'm a bit more behind 😮

The release candidate blog post doesn't seem to list any changes in supported versions of SQL Server, but I can see that the NPoco dependency was updated.

idseefeld commented 1 year ago

Looks like it is caused by an dependency update of Microsoft.Data.SqlClient to version 5.0.1. I found a nice article which also gives a solution: https://weblog.west-wind.com/posts/2021/Dec/07/Connection-Failures-with-MicrosoftDataSqlClient-4-and-later

The short clue is to add the following setting to the connection string: ;Encrypt=False

Currently you can do this only with the CLI or unattended settings. I have tried Paul Seals Package Script Writer and it worked.

idseefeld commented 1 year ago

@prjseal told me: ;TrustServerCertificate=true; instead of ;Encrypt=false; would be the preferred way to handle this. I have tried this too and it works.

Btw. there is a quite long discussion about this at https://github.com/dotnet/SqlClient/issues/1402.

Microsoft documentation of TrustServerCertificate can be read here: https://learn.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnectionstringbuilder.trustservercertificate?view=dotnet-plat-ext-7.0 and in more details at: https://learn.microsoft.com/en-us/sql/relational-databases/native-client/features/using-encryption-without-validation?view=sql-server-ver16.

My understanding is: You can use either ;TrustServerCertificate=true; or ;Encrypt=false; in development environments, but in production you should configure the SQL server with a valid certificate.

For the installer UI I think there should be a checkbox for this additional parameter and documentation should mention this issue or new requirement.

prjseal commented 1 year ago

I’ll add this to package script writer next week so it works with SQL Server

kjac commented 1 year ago

Hi everyone 👋

Thank you all very much for digging into this. I do agree, we need to address this in the V12 installer somehow. I will bring it to the team Monday morning for an internal discussion.

How lucky we are to have people like you folk running the RC's through the paces! ❤️

prjseal commented 1 year ago

This has been added to Package Script Writer now. Example Here

Zeegaan commented 1 year ago

This has been fixed in https://github.com/umbraco/Umbraco-CMS/pull/14361, sorry for the late update 🚀