Featured

Configure SSL encryption for SQL Server using Wildcard Certificate

 

It’s been while I did some writing, thought to share some good stuff came across during last couple of years, one of them was implementing SSL (wildcard certificate) with SQL Server 2012.

yeah!!! I did it.

I am not going to explain here on what is SSL and how it works and blah blah all the technical stuff, for that I will have related reference links at the end of this page that you can use to build the technical knowledge.

To make it simpler I will keep the article maximum to text only.

Note: wildcard SSL support was added to SQL Server 2008 R2 and later versions.

example of wildcard certificate *.xyzdomain.com

 

Step 1: (import SSL Certificate)

Import wildcard SSL certificate on the MS SQL Server. that’s going to be the usual import process that we perform mostly in our environments.

Step 2: (certificate not listed in SCM dropdown menu)

in most of the cases wildcard certificates are not shown in SQL Server Configuration Manager Dropdown list. and my method of configuration was to follow the registry keys and the support to SQL Server.

You can see the certificate if you open up mmc and add the snap-in for Certificates. When asked to chose the account, select “Computer Account” for the Local computer. Both of the above certificates will be present under Personal –> Certificates

once you see the certificate is listed here you need to use the following command to get the wildcard SSL certificate hash value.

open command prompt with elevated permissions and use the following command

*** certutil –store “my” ***

wildcard

look at the highlighted Cert Hash(sha1) value, copy it and take it to notepad. or use the next command and redirect the output to a text file.

*** certutil –store “my” > c:\temp\certlist.txt ***

open this certlist.txt and look for your required wildcard certificate Hash value.

copy the value and carefully remove the spaces

Step 3: (add hash value to registry)

Open up the registry (regedit) and navigate to the SQL Server instance hive. the default location for SQL Server would be

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQLServer\SuperSocketNetLib

ssl-registry

create a string value “Certificate” on the above location or modify already created value and Paste the hash value noted in step-2.

once completed this step restart SQL Server Service to load the SSL Certificate.

Step 4: (force encryption = true)

on the same registry location change the “ForceEncryption” value to 1 as show in the image of step-3

or use the SQL Configuration manager to enforce the encryption

ssl-enforce

once completed this step restart SQL Server Service to load the SSL Certificate.

Troubleshooting :

SQL Server Service not starting after adding the registry value, no need to panic, you need to check couple of things.

some of the errors can be seen in error logs.

TDSSNIClient initialization failed with error 0x80092004, status code 0x80. Reason: Unable to initialize SSL support. Cannot find object or property.

TDSSNIClient initialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property.

Unable to load user-specified certificate [Cert Hash(sha1) “your certificate hash value“]. The server will not accept a connection. You should verify that the certificate is correctly installed.

1. verify that SQL Server Service user has rights to read the Certificate.

identify the service account it could be a domain account or any of the built-in accounts like LocalService/NetworkService by going to services.

grant read permission to this user on SSL certificate.

Open MMC with certificates snap-in for local computer

Expand Certificates (Local Computer) -> Personal -> Certificates and find the wildcard SSL certificate.

Right click on the certificate and click All Tasks -> Manage Private Keys.

Click the Add button under the Group or user names list box.

enter the SQL Server service user identified earlier and click ok.

Now start the SQL Service again and in my case it was like Bingo!!!!.

 

2. verify that SQL Server Certificate is not expired.

if the certificate is expired buy a new certificate any certificate authority and follow the same process.

3. verify that the hash value is added without any spaces.

this is tricky. export the selected registry key and open the *.reg (exported file) with notepad. now save as “type the new file name.reg” and choose the encoding “ANSI”.

 

open the newly created registry file and see if you find any “?” or space in the HASH value. if yes, remove it and save. now you can import this registry file by double clicking on it. and restart the service.

this step was important for me and I was able to solve my service starting issue with this step in my staging environment.

 

that’s all folk’s!!!

 

References :

How to enable SSL encryption for an instance of SQL Server by using Microsoft Management Console
https://support.microsoft.com/en-us/kb/316898

Encrypting Connections to SQL Server
https://msdn.microsoft.com/en-us/library/ms189067.aspx

How to Enable Channel Encryption
https://blogs.msdn.microsoft.com/sql_protocols/2005/10/03/how-to-enable-channel-encryption/

Accepted wildcards used by server certificates for server authentication
https://support.microsoft.com/en-us/kb/258858

Configure Windows Service Accounts and Permissions
https://msdn.microsoft.com/en-us/library/ms143504.aspx#Registry
https://msdn.microsoft.com/en-us/library/ms143504.aspx#Windows

Configuring the SQL Server clients to use encrypted connections

 

in continuation to my last post, here we will learn how to use clients to connect with SQL Server using encrypted channel. there are different ways of connecting with SQL Server using encrypted channel. here I will share using SQL Management Studio & Connection String using “web.config”.

 

SQL Server Management Studio
1. in SQL Management Studio, while tying SQL Server Address, Login ID & Password. click on the Options button
2. On the “Connection Properties”, check the box for “Encrypt Connection”

sql-connection

3. if the server certificate is untrusted you can click on the “Additional Connection Parameters” tab and enter “TrustServerCertificate=True”.

sql-connection2

4. Click the ‘Connect’ button

 

WEB.CONFIG Connection String

Connection String, you need to add the “ENCRYPT=TRUE” in the connection string in addition to FQDN for your SQL Server address, it is important to use FQDN instead of IP address for SQL Server in the connection string.

connectionstrin

 

That’s All Folks.

Setup Core Server on Network–Windows 2008

 

it is normal practice for a sysadmin to configure a machine on network; in GUI mode its easy like 1,2,3…

but in core server case its it like ,99,98,97.. Smile

means its to that simple if you are not familiar with windows command line and its syntax; we had this in windows 2003 as well.

ok not making it complex but here are few commands to configure the windows 2008 core system on the network;

Let’s start windows server Name:

Configure Server Name:

on command prompt use the following commands :

  1. hostname” (to check the current computer name) (if required)
  2. “netdom renamecomputer %computername% /NewName:Core-Srv01”
  3. ”shutdown /r /t 0” (Reboot your Server)

command prompt, type the following: netsh interface ipv4 show interfacesAssign Static IP Address to Server Core:

now type: “netsh interface ipv4 set address name=”Local Area Connection” static 192.168.5.1 255.255.255.0 192.168.5.1 2”


Name: Name of Connection as shown in step 1Sequence:
    • Static: indicates the you are going to assign a static IP to server following to static IP SUBNET Gateway and IDx Number
    • IDx Number is also shown in step 1

 

Assign DNS Server address

  1. type: “netsh interface ipv4 add dnsserver “Local Area Connection” 192.168.20.10 index=1”

Verify by typing ipconfig /all and checking that all the addresses are correct.Index is the Priority index of DNS (e.g preferred DNS , Alternate DNS)DNSIP is the IP address of your DNS server

 

Join Computer to domain:

Windows 2008 as Member Server :

on server core type: “netdom join %ComputerName% /Domain:TestLab.Local /UserD:admin@testlab.local /PasswordD:*”

Type the password: and hit Enter

on successful message reboot with “shutdown /r /t 0”


Enable remote Desktop on Server Core:
in addition you can also set a automatic reboot on successful join Just add “/reboot” at the end of command;

To enable remote administration from Windows Vista/Windows 2008; Write the following command:

Cscript %windir%\system32\SCRegEdit.wsf /ar 0

To enable remote administration from Windows XP/2003 and earlier operating system; Write the following command:
Cscript %windir%\system32\SCRegEdit.wsf /cs 0

it is obvious the press ENTER at the end of command Smile

ADD access Rule in firewall:

 

netsh advfirewall firewall set rule group=”Remote Desktop” new enable=yes

 

Set Time ZONE & Date:

on Server Core 2008 type: “control timedate.cpl”

Change International settings (Regional & Language Options)

On Server Core 2008 type: “control intl.cpl”

 

I hope this blog will help you in setting up your server on network;

These commands are tested on VMLAB using windows 2008 Enterprise Edition (Trial)

Windows 2008–Core

 

Windows 2008 Core ; it is a server with minimal installation option; no GUI but has a GUI…

Its like you are working on command line operating system; I would not say like Linux or any other thing but yet it is a command line Operating system from Microsoft; some commands prompts you the answer in Standard windows message box … I don’t know why… Smile

rather comparing it to any other OS I will simply continue how to install it;

Benefits of Installing Server Core

    1. Reduced Disk Space Usage for installation
    2. Reduced Attack surface (Reason is that you have only require applications running on it which decreases the attack surface)
    3. There is no or limited GUI; Management Interface is Command Line.
    4. Reduced Management because the less you install the Less you manage…

there are more but I am not getting into it…

What you need to start the installation

    1. windows 2008 installation media
    2. License Key or you can use Trail version
    3. a Computer that can Run windows 2008 server ; VHD can also be done; you can read my previous blog on how to install windows on VHD.

Installation:-

  1. boot from windows 2008 DVD;
  2. Choose your desired language;
  3. Click Install now;
  4. Select the windows 2008 Core installation edition you want to install;
  5. continue to the installation to complete;

Post Installation

Once we have windows 2008 logon screen (CTRL+ALT+DEL)

you will be prompted to change the password as logon (Password Change is Must)

Setup Core Server Read Here