KB10119 - MSSQL: Implement SSL/TLS
KB10119 - MSSQL: Implement SSL/TLS
I am not the SQL guy but this "problem" was so stupid and there was no real description on one page what to manage to enable SSL/TLS on MSSQL Servers so I decided to write down the required steps just to know and to remember...
Steps:
- Request a certificate
- Open a MMC and add the certificates snap in for the local computer
- Go to Personal and request a new certificate
This description is written in an Active Directory environment so there is a MS CA with policies enrolled - Context menu -> All Tasks -> Advanced Operations -> Create Custom Request...
- You can use a certificate with an enrolment policy
- OU you can complete with a custom request (in this case
- Select a Template which is used for "Server Authentication" (OID: 1.3.6.1.5.5.7.3.1)
If you work without policy select "no template legacy key" - On the "General" tab key in a friendly name for the certificate (I prefer to use the DNS alias in here...)
- On the "Subject" Tab
In the screenshot the REAL FQDN name is "srvsql1.schnitzelbroetchen.info" and the DNS alias is "mssql.schnitzelbroetchen.info" - Select "Common name" as subject and enter the servers REAL FQDN name here (((Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain).Tolower())
- Add this name also as alternative name with type DNS (Not mandatory)
- If the clients use a DNS alias for the connection you can add additional names here.
- On the "Extensions" Tab
- Ensure "Digital signature" and "Key encipherment" is enabled as Key usage
- and "Server Authentication" is enabled as Extended Key usage
- On the "Private Key" key tab
- Select "Microsoft RSA SChannel Cryptographic Provider (Encryption)" and "Microsoft DH SChannel Cryptographic Provider (Encryption)" as CSPs
- Select a key size with at least 2048 bit
- Make the private key exportable (if allowed an required)
- Select "Use custom permissions" under Key permissions
- Add the username under whitch the SQL service gest started (you can find this one in the services.msc)
- Now you can save the request as file or send it directly to an online CA
- If the request is saved to a file you have to request a new certificate for this request.
- If you have to manually import the certificate
- Open the context menu of the certificates mmc and select All Tasks -> Import
- Open the certificate file an select personal as target store
- Install the certificate to MSSQL
At this point the certificate including the private key is installed on the SQL Server - Open the "SQL Server 20xx Configuration Manager"
- Go to "SQL Server Network Configuration"
- right click "Protocols for xxx" where xxx is you instance name and select "Properties"
- On the "Certificate" Tab select the new certificate created
If it is not visible here you probable missed something in the request ;-) - To enforce encryption select "Yes" in "Force Encryption" in the "Flags" tab
- Restart SQL service
- When the service starts everything is fine and you now can or have to use encrypted connections to the SQL Server
- If not please check the event log in my case the "problem" was always that the service account running SQL service had no permission to the certificates private key.