Configuring Certificate-based Authentication in SQL Server Express' Distributed Service Broker EnvironmentOctober 20, 2008 In the recent articles of our series dedicated to the most prominent
features incorporated into SQL Server 2005 Express Edition, we have been
discussing Service Broker functionality. So far we have presented a couple of
scenarios demonstrating implementation of a sample dialog between two services
residing in the same database and an equivalent arrangement taking place in a
distributed environment. As we have pointed out, while the former could be
conducted without any security-related provisions, the latter, at the minimum,
required the presence of an authentication mechanism (which facilitates Service
Broker transport security). For the sake of simplicity, we decided to use
Windows-based Kerberos protocol (as determined by the value of Certificate-based authentication is based on the principle of asymmetric cryptography, which involves the concept of public and private digital key pairs as well as the certificates associated with them (representing the relationship between the matching keys and identifying their owner). Access to the private key is secured and available strictly to its owner, while the public, as its name indicates, might be safely exposed (via its certificate) without jeopardizing confidentiality of its counterpart. At the same rate, both of them are related in a unique manner, such that any piece of data encrypted with the former can be reconstructed using the latter. This confirms the authenticity of its origin with a high degree of certainty. The reverse operation is also possible, thus providing encryption capabilities, which we will be covering in future articles). In the context of Service Broker communication, it is possible to leverage this behavior to authenticate two endpoints. This is accomplished by configuring each of them with a locally stored private key and having the matching public key deployed (in the form of its certificate) to the communication partner. In addition, on each server, you need to designate a login (and a corresponding master database user) in which security context all conversations will be conducted, authorized to access a certificate representing the remote side and granted the privileges required to connect to the local endpoint. Let's take a look at a sample implementation of this scenario. We will leverage previously created SQL Server 2005 objects (for the
relevant T-SQL statements, refer to one of
the earlier articles of our series), including two databases ( While using third party certificates is possible, for the purpose of our
example, we will take advantage of equivalent functionality incorporated into
SQL Server 2005 platform (especially considering that validation process
employed by the database engine does not track their origin, but only verifies
that their expiration date has not yet passed). This involves creating
self-signed X.509 certificates (by invoking -- on srvExp01 USE master GO CREATE MASTER KEY ENCRYPTION BY PASSWORD = '1m$0C0mPleX' GO CREATE CERTIFICATE cert_SB_01_Express WITH SUBJECT = 'SB_01_Express Certificate' GO BACKUP CERTIFICATE cert_SB_01_Express TO FILE = 'C:\Temp\cert_SB_01_Express.cer' GO CREATE ENDPOINT EP_SB_01_Express STATE = STARTED AS TCP (LISTENER_PORT = 4022) FOR SERVICE_BROKER ( AUTHENTICATION = CERTIFICATE cert_SB_01_Express, ENCRYPTION = DISABLED); -- on srvEnt01 USE master GO CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'H@rD2GuE$$' GO CREATE CERTIFICATE cert_SB_02_Enterprise WITH SUBJECT = 'SB_02_Enterpise Certificate' GO BACKUP CERTIFICATE cert_SB_02_Enterprise TO FILE = 'C:\Temp\cert_SB_02_Enterprise.cer' GO CREATE ENDPOINT EP_SB_02_Enterprise STATE = STARTED AS TCP (LISTENER_PORT = 4022) FOR SERVICE_BROKER ( AUTHENTICATION = CERTIFICATE cert_SB_02_Enterprise, ENCRYPTION = DISABLED); Since the authentication takes place on the transport level (which might
involve multiple dialogs between services sharing the same endpoints), initiator
and targets cannot be uniquely identified by relying solely on its provisions.
As the result, you will need to grant SEND permissions on both services to the
Public role in both -- on srvExp01 USE dbSBExp01 GO GRANT SEND ON SERVICE::[//databaseJournal.com/SQL2005EX/ServiceBroker/svcSend] TO Public -- on srvEnt01 USE dbSBEnt01 GO GRANT SEND ON SERVICE::[//databaseJournal.com/SQL2005EX/ServiceBroker/svcRecv] TO Public In the next article of our series, we will present the remaining steps necessary to establish Service Broker dialog in the distributed environment while leveraging certificate-based authentication. |