如何:允許 Service Broker 網路使用憑證進行存取 (Transact-SQL)

適用於:SQL ServerAzure SQL 受控執行個體

若要允許另一個執行個體使用以憑證為基礎的 Service Broker 傳輸安全性傳送訊息,您可以為其他執行個體建立使用者並安裝憑證。

若要允許從另一個執行個體使用憑證進行存取

  1. 從受信任的來源取得其他執行個體的憑證。 通常,這涉及使用加密的電子郵件傳送憑證,或在實體媒體 (如磁片) 上傳送憑證。

    注意

    僅安裝來自受信任來源的憑證。

  2. 建立登入。

  3. master 資料庫中建立用於登入的使用者。

  4. master 資料庫中,安裝其他執行個體的憑證。 在步驟 3 中建立的使用者擁有該憑證。

  5. 將 Service Broker 端點的 CONNECT 存取權授與登入。

  6. 傾印用於本機執行個體中之 Service Broker 傳輸安全性的憑證。

    注意

    只會傾印用於傳輸安全性的憑證。 請勿傾印或散發與憑證相關聯的私密金鑰。

  7. 提供憑證給其他資料庫的管理員。 遠端資料庫的管理員會使用上述的步驟 1-4 來安裝此憑證。

一旦在每個執行個體中設定了存取,則兩個執行個體間的通訊會在這兩個執行個體的端點都設定為允許傳輸安全性時,使用 Service Broker 傳輸安全性。

範例

    USE master ;
    GO

    -- Create a login for the remote instance.

    CREATE LOGIN RemoteInstanceLogin
        WITH PASSWORD = '#gh!3A%!1@f' ;
    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

另請參閱