Install PFX Certificate on SQL Server 2008 R2 – How to Install a PFX Certificate on SQL Server 2008 R2

certificatesql serversql-server-2008-r2windows

We have a MS SQL 2008 R2 service running on a Windows 7 computer. I've developed a webapplication that runs on a Digital Ocean droplet. This droplet makes a connection with this computer through a subdomain "sql.client-domain.ext" (fictive domain name).

There is a firewall which only allows connections from the droplet to the computer where SQL service is running.

I want an encrypted connection between the droplet and the computer. I've purchased a certificate.

On my local test machine I've installed the PFX certificate in the personal folder (in MMC). I've added the 'NETWORK SERVICE' user with READ permissions for the certificate key.

In the SQL management console, I can't see the certificate anywhere. I tried with service restarts, nothing.

I've also tried to change the hostname to the subdomain and added the subdomain in the hosts file under the Windows directory.

EXEC sp_addserver 'sql.client-domain.ext', local; 

Host file: 127.0.0.1 sql.client-domain.ext

I can connect in the SQL client program to sql.client-domain.ext but I can't pick the certificate.

I only need the certificate for TCP connections, not local connections.

Any hints or experienced advice?

Best Answer

Plase try to follow this steps:

  • Launch the Microsoft Management Console. Select File > Add/Remove snap-in:

enter image description here

  • Add a Certificates snap-in:

enter image description here

  • Select “Computer account”:

enter image description here

  • Use the Local Computer:

enter image description here

  • With the snap-in now configured, right-click on the “Personal” certificate store folder, select All Tasks > Import:

enter image description here

  • Use the certificate import wizard to select the .PFX file to import. In either case, follow the import wizard instructions. Enter the password set when the PFX file was created. Ensure that “Include all extended properties” is selected:

enter image description here

  • Select “Place all certificates in the following store” and choose the “Personal” store:

enter image description here

Once the certificate has been imported, SQL Server must be configured to use it. The SQL Server configuration manager for SQL Server 2008/R2 has an option to set the certificate associated with an instance, by opening the “SQL Server Networking Configuration,” right-clicking on “Protocols for ,” and opening the Certificate tab. However, this method cannot be used to select any certificate other than a machine certificate for servers that belong to a domain.

  • Find the “Thumbprint” of the certificate, and copy it to the clipboard. In the certificate management console, it can be found by opening the certificate, selecting the “Details” tab, scrolling to the bottom of the field list, and selecting “Thumbprint”:

enter image description here

  • After locating the thumbprint, copy it out of the certificate viewer, paste it into notepad, remove all of the spaces, and copy the modified thumbprint back to the clipboard. Be careful – it’s easy to make a mistake.

    • Open regedit
    • Navigate to: HKLM\Software\Microsoft\Microsoft SQL Server\MSSQLServer\SuperSocketNetLib
    • Locate the “Certificate” entry
    • Assign its value to the thumbprint copied out of the certificate, e.g.:

enter image description here

The instance must be restarted for the changes to take effect.