若要允许另一个实例使用基于证书的 Service Broker 传输安全模式来发送消息,请为该实例创建用户并安装证书。
允许使用证书从另一个实例访问
从可信源为另一个实例获取证书。 通常,这涉及到使用加密电子邮件发送证书或在物理媒体(如软盘)上传输证书。
注意
仅安装受信任源的证书。
创建一个登录名。
为数据库中的登录
master名创建用户。在数据库中安装其他实例的
master证书。 步骤 3 中所创建的用户拥有该证书。授予对 Service Broker 终结点的登录
CONNECT访问权限。转储本地实例中用于 Service Broker 传输安全性的证书。
注意
只转储用于传输安全模式的证书。 不要转储或分发与证书关联的私钥。
将该证书提供给另一个数据库的管理员。 远程数据库的管理员使用前面的步骤 1 - 4 安装此证书。
每个实例中都配置了访问权限后,当两个实例的端点都被配置为允许传输安全性时,这两个端点间的通信将使用 Service Broker 传输安全模式。
例子
USE master;
GO
-- Create a login for the remote instance.
CREATE LOGIN RemoteInstanceLogin WITH PASSWORD = '<password>';
GO
-- Create a user for the login in the master database.
CREATE USER RemoteInstanceUser FOR LOGIN RemoteInstanceLogin;
GO
-- Load the certificate from the file system. Notice that
-- the login owns the certificate.
CREATE CERTIFICATE RemoteInstanceCertificate
AUTHORIZATION RemoteInstanceUser
FROM FILE = 'C:\Certificates\AceBikeComponentsCertificate.cer';
GO
GRANT CONNECT ON ENDPOINT::ThisInstanceEndpoint TO RemoteInstanceLogin;
GO
-- Write the certificate from this instance
-- to the file system. This command assumes
-- that the certificate used by the Service Broker
-- endpoint is named TransportSecurity.
BACKUP CERTIFICATE TransportSecurity
TO FILE = 'C:\Certificates\ThisInstanceCertificate.cer';
GO