Unable to Connect to SQL Server, Getting SSL Error

The stream or file "/var/www/html/storage/logs/laravel-2023-08-20.log" could not be opened in append mode: Failed to open stream: Permission denied The exception occurred while attempting to log: SQLSTATE[08001]: [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate] (Connection: sqlsrv, SQL: select top 1 * from [cache] where [key] = laravel_cache_config) Context: {"exception":{"errorInfo":["08001",-1,"[Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:self signed certificate]","08001",-1,"[Microsoft][ODBC Driver 18 for SQL Server]Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722"],"connectionName":"sqlsrv"}}

Hi!

Can you perhaps clarify how your issue is related with Let's Encrypt? Because you're now posting on the Let's Encrypt Community. While we sometimes also help with generic TLS issues, this is practically almost related to Let's Encrypt in some way or perhaps related to the ACME protocol.

For generic TLS issues, this is probably not the correct Community for you.

1 Like

What do you mean with "I have added the SSL from Let's Encrypt"? Because indeed your website uses a Let's Encrypt certificate, but is that also the case for MS SQL Server?

2 Likes

I think this is one of those "anything about SSL" questions rather than Let's Encrypt specific, but if you are using a self-signed certificate (the default) then you need to explicitly trust the cert in your connection string with TrustServerCertificate=true

E.g.:

Server=(local)\SQLEXPRESS;Database=Contoso;User Id=app_user;Password=app_pwd;TrustServerCertificate=true;

If you want to use a real trusted certificate for SQL server you can, you need to apply a certificate covering the name you want to SQL Server, then when you access it in your connection string use the proper name from the certificate:

Server=example-sql.domain.com\SQLEXPRESS;Database=Contoso;User Id=app_user;Password=app_pwd;

I have no idea how SQL Server on Linux (if that's what you're using) let's you apply a certificate, but on Windows you can do it with a registry update (for example, using powershell: Scripting | Certify The Web Docs )

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.