0

i want to do certificate based authentication for SQL using powershell.

My current code is below for building connection with database:

##SQL PART
$connString = "Data Source=$SqlServer;Database=$Database;User ID=$SqlAuthLogin;Password=$SqlAuthPw"
        
#Create a SQL connection object
$conn = New-Object System.Data.SqlClient.SqlConnection $connString
        
#Attempt to open the connection
$conn.Open()

I can't use any other ways to pass password as there are some limitations.

As I'm new to this what further steps should I take to do certificate based authentication will really be helpfull.

Thanks

11
  • Why don't you use integrated security? Commented Oct 3, 2022 at 7:49
  • The scenarios where (on-prem) SQL Server supports certificate-based authentication are limited to machine-to-machine communication. You cannot use a client certificate mapped to a user to log in to SQL Server (this role is mostly taken up by integrated security). Azure SQL does support certificate-based authentication, but this mechanism goes through Azure AD and is quite different (docs). Commented Oct 3, 2022 at 8:54
  • Authentication usually refers to a client server HTTP/HTTPS connection. SQL Server either uses Windows Credentials or SQL Credentials (username and password). Certificates are normally used with a HTTPS using TLS. It is not clear where you need to use a certificate. Commented Oct 3, 2022 at 10:45
  • @jdweng, thanks for reply , but instead of passing password in connection string i want to use certificate for that. Is it possible to do so. Commented Oct 7, 2022 at 7:01
  • @JeroenMostert, thanks for reply , my sql server is on prem server and i want to pass password through certificates instead of some encryption or plain text , is it possible to do so. Commented Oct 7, 2022 at 7:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.