From 37f16ca80abf95716805f45e5246fa9c6532a2d1 Mon Sep 17 00:00:00 2001 From: Ramiro Morales Date: Mon, 15 Oct 2018 14:41:46 -0300 Subject: [PATCH] Add 'encrypt' setting to MSSQL data source. Fixes #13629 --- docs/sources/features/datasources/mssql.md | 6 +----- pkg/tsdb/mssql/mssql.go | 4 +++- .../datasource/mssql/partials/config.html | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/sources/features/datasources/mssql.md b/docs/sources/features/datasources/mssql.md index 4a3478b161a..b104a5a1376 100644 --- a/docs/sources/features/datasources/mssql.md +++ b/docs/sources/features/datasources/mssql.md @@ -32,6 +32,7 @@ Name | Description *Database* | Name of your MSSQL database. *User* | Database user's login/username *Password* | Database user's password +*Encrypt* | This option determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server, default `false` (Grafana v5.4+). *Max open* | The maximum number of open connections to the database, default `unlimited` (Grafana v5.4+). *Max idle* | The maximum number of connections in the idle connection pool, default `2` (Grafana v5.4+). *Max lifetime* | The maximum amount of time in seconds a connection may be reused, default `14400`/4 hours (Grafana v5.4+). @@ -70,11 +71,6 @@ Example: Make sure the user does not get any unwanted privileges from the public role. -### Known Issues - -MSSQL 2008 and 2008 R2 engine cannot handle login records when SSL encryption is not disabled. Due to this you may receive an `Login error: EOF` error when trying to create your datasource. -To fix MSSQL 2008 R2 issue, install MSSQL 2008 R2 Service Pack 2. To fix MSSQL 2008 issue, install Microsoft MSSQL 2008 Service Pack 3 and Cumulative update package 3 for MSSQL 2008 SP3. - ## Query Editor {{< docs-imagebox img="/img/docs/v51/mssql_query_editor.png" class="docs-image--no-shadow" >}} diff --git a/pkg/tsdb/mssql/mssql.go b/pkg/tsdb/mssql/mssql.go index 72e57d03fa0..e1d6904d58f 100644 --- a/pkg/tsdb/mssql/mssql.go +++ b/pkg/tsdb/mssql/mssql.go @@ -52,12 +52,14 @@ func generateConnectionString(datasource *models.DataSource) string { } server, port := hostParts[0], hostParts[1] - return fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s;", + encrypt := datasource.JsonData.Get("sslmode").MustString("false") + return fmt.Sprintf("server=%s;port=%s;database=%s;user id=%s;password=%s;encrypt=%s;", server, port, datasource.Database, datasource.User, password, + encrypt, ) } diff --git a/public/app/plugins/datasource/mssql/partials/config.html b/public/app/plugins/datasource/mssql/partials/config.html index 4cb42e90f7c..d8e1eb1ec00 100644 --- a/public/app/plugins/datasource/mssql/partials/config.html +++ b/public/app/plugins/datasource/mssql/partials/config.html @@ -27,6 +27,22 @@ reset + +
+ +
+ + + Determines whether or to which extent a secure SSL TCP/IP connection will be negotiated with the server. +
    +
  • disable - Data sent between client and server is not encrypted.
  • +
  • false - Data sent between client and server is not encrypted beyond the login packet. (default)
  • +
  • true - Data sent between client and server is encrypted.
  • +
+ If you're using an older version of Microsoft SQL Server like 2008 and 2008R2 you may need to disable encryption to be able to connect. +
+
+
Connection limits