Subscribe in a reader" />
Welcome to TechNet Blogs Sign in | Join | Help

Andrew Fryer's Blog

Insufficient Data

News

SQL Server 2008 - Transparent Data Encryption

One of the new things you can do in CTP5 of SQL Server 2008 is to encrypt your databases so that they are protected at rest and so are any backups made from them.  So this prevents anybody from accessing a database without going through the server it belongs to.

To move an encrypted database from one server to another you would need to move the key that encrypted it as well. For example you might send the key be e-mail and then send the database on CD's in the post.

First you need a master key and then a certificate:

USE master;
GO
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'UseStrongPassword1!'; --SMK????
GO
CREATE CERTIFICATE MyServerCert WITH SUBJECT = 'My DEK Certificate for Sensitive Data' GO

Then you can use this to encrypt the database with this:

USE Retail_DWH
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_128
ENCRYPTION BY SERVER CERTIFICATE MyDBCert

The encryption process runs as a background task and the database is available during the process.

It's a really good idea to back up the certificate as without it you can't get the database or backups back - whihc of course is the whole objective! 

This script backs up the certificate to a temp folder as an example:

BACKUP CERTIFICATE MyServerCert
TO FILE = 'c:\temp\MyServerCert'
WITH PRIVATE KEY (file='c:\temp\MyServerCertKey',
ENCRYPTION BY PASSWORD='UseStrongPassword1!')

To move this to another instance or server the first step is to create a master key on the new server:

create master key encryption by password = 'UseDifferentStrongPassword1!'

The certificate can then be restored like this:

create certificate MyServerCert
from file='c:\temp\MyServerCert'
with private key (
file = 'c:\temp\MyServerCertKey',
decryption by password='UseStrongPassword1!')

So very simple to setup, easy to use

Technorati Tags: ,
Posted: Thursday, November 29, 2007 11:49 AM by Andrew_Fryer

Comments

David Sugarman said:

We do a good line in sending databases via the post here in the UK :-)

# November 30, 2007 4:20 AM

Chris Latham said:

Thanks for the demo of this last night Andrew - well done for keeping your head as projectors blew up and the local scallies were banging on the windows!

Seriously though, this and the backup compression are little tweaks which make 2008 an attractive proposition from the IT Professional's standpoint.

Thanks for a very enjoyable event.

# November 30, 2007 8:00 AM

Mike Ormond's Blog said:

Andrew's turning into a really useful guy. He also has a great post on TDE here . :-) Technorati Tags:

# December 5, 2007 7:12 AM

Noticias externas said:

Andrew's turning into a really useful guy. He also has a great post on TDE here . :-) Technorati

# December 5, 2007 8:08 AM

John Baker said:

Is there any difference between this solution and just using EFS on your filesystem? Using EFS has been an option since Win 2k and from what I see it provides the same results.

http://www.sqlservercentral.com/articles/Administering/implementing_efs/870/

# December 5, 2007 10:08 AM

Andrew_Fryer said:

John.  EFS won't protect the backup or the MDF, LDF database files if you put those on a  CD, but TDE does do that.  Andrew

# December 7, 2007 7:03 AM

Sean said:

Here are 2 big disadvantages to EFS and BitLocker from MS "Detaching or backing up the database to a different volume that is not protected by EFS or BitLocker causes any protection the file currently has to be lost. The other disadvantage of BitLocker is the broad scope of protection. Because the entire volume is unlocked, any user with access to a computer that can access the files on disk can access the data in plaintext."  Reference http://msdn.microsoft.com/en-us/library/cc278098.aspx

# November 14, 2008 5:35 PM

Andrew_Fryer said:

Sean,

Completely agree, but Your point about bitlocker is also true of the RSA encryption used by manby UK govenrment departments.

so it's important to pick the right tool for the job.  field encryption within the database, might make sense to protect credit card numbwers.  TDE stops the database being moved to another location without the certificate. EFS / bitlocker are the only offerings form Micrsoft to protect filestream, and if these aren't sufficent to meet your needs then there are numerous third aprty tools thiat might.  

Andrew

# November 17, 2008 2:48 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker