Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/pmdas/mssql/mssql.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[connection]
driver={ODBC Driver 17 for SQL Server}
driver={ODBC Driver 18 for SQL Server}
server=tcp:localhost
timeout=2
## Set to true when SQL Server uses a self-signed TLS certificate (common on Linux installs)
#trust_server_certificate=true

[authentication]
## General reference on authentication options
Expand Down
9 changes: 7 additions & 2 deletions src/pmdas/mssql/pmdamssql.python
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ class MSSQLPMDA(PMDA):
try:
self.driver = conf_vars["connection.driver"]
except:
self.driver = "{ODBC Driver 17 for SQL Server}" # default driver
self.driver = "{ODBC Driver 18 for SQL Server}" # default driver
try:
self.server = conf_vars["connection.server"]
except:
Expand All @@ -1038,7 +1038,10 @@ class MSSQLPMDA(PMDA):
self.trusted = self.intobool(conf_vars["authentication.trusted"])
except:
self.trusted = False
print("trusted?",self.trusted)
try:
self.trust_server_certificate = self.intobool(conf_vars["connection.trust_server_certificate"])
except:
self.trust_server_certificate = False
# first try Assessment API credentials, else our local config file,
# otherwise just use defaults of user 'pcp' with an empty password.
self.username = pmContext.pmGetConfig('PCP_USER')
Expand Down Expand Up @@ -1299,6 +1302,8 @@ class MSSQLPMDA(PMDA):
parameters = 'DRIVER={0};SERVER={1};UID={2};PWD={3}'
parameters = parameters.format(self.driver, self.server,
self.username, self.password)
if self.trust_server_certificate:
parameters += ';TrustServerCertificate=YES'

try:
self.conn = pyodbc.connect(parameters, timeout=self.timeout)
Expand Down
Loading