共用方式為


使用全像攝影遠端處理和 OpenXR API 保護連線

使用 OpenXR API 時,所有安全連線相關的 API 都可作為 OpenXR 擴充功能的一 XR_MSFT_holographic_remoting 部分。

重要事項

若要瞭解全像攝影遠端 OpenXR 擴充 API,請參閱全像攝影遠端範例 Github 存放庫中可找到的規格

請記住,如果您想要啟用連線安全性,就必須實作自定義遠端和播放機應用程式。 這兩個自定義應用程式都需要:

  • 如果應用程式以伺服器身分執行,則為憑證提供者和驗證驗證程式。
  • 如果應用程式是以用戶端身分執行,則為驗證提供者和憑證驗證程式。

OpenXR API 類似於處所述的 Windows Mixed Reality API。 不過,使用 XR_MSFT_holographic_remoting OpenXR 擴充功能進行安全連線的主要元素不是實作介面,而是下列回呼:

  • xrRemotingRequestAuthenticationTokenCallbackMSFT、產生或擷取要傳送的驗證令牌。
  • xrRemotingValidateServerCertificateCallbackMSFT,驗證憑證鏈結。
  • xrRemotingValidateAuthenticationTokenCallbackMSFT,驗證客戶端驗證令牌。
  • xrRemotingRequestServerCertificateCallbackMSFT,為伺服器應用程式提供要使用的憑證。

注意事項

使用全像攝影遠端處理時,播放機或遠端可能是伺服器,視您的需求而定 (如需詳細資訊,請參閱 全像攝影遠端術語) 。 如果您的自定義遠端或自定義播放機應用程式可以作為客戶端和伺服器執行,則應用程式必須提供全部四個回呼。

回呼可以透過和 xrRemotingSetSecureConnectionServerCallbacksMSFT提供給遠端的 OpenXR 執行時間xrRemotingSetSecureConnectionClientCallbacksMSFT。 若要這樣做,您可以建立回呼的靜態函式:

class SecureConnectionCallbacks {
public:
    ...

    // Static callbacks
    static XrResult XRAPI_CALL
    RequestAuthenticationTokenStaticCallback(XrRemotingAuthenticationTokenRequestMSFT* authenticationTokenRequest) {
        if (!authenticationTokenRequest->context) {
            return XR_ERROR_RUNTIME_FAILURE;
        }
        return reinterpret_cast<SecureConnectionCallbacks*>(authenticationTokenRequest->context)
            ->RequestAuthenticationToken(authenticationTokenRequest);
    }

    static XrResult XRAPI_CALL
    ValidateServerCertificateStaticCallback(XrRemotingServerCertificateValidationMSFT* serverCertificateValidation) {
        if (!serverCertificateValidation->context) {
            return XR_ERROR_RUNTIME_FAILURE;
        }
        return reinterpret_cast<SecureConnectionCallbacks*>(serverCertificateValidation->context)
            ->ValidateServerCertificate(serverCertificateValidation);
    }

    static XrResult XRAPI_CALL
    ValidateAuthenticationTokenStaticCallback(XrRemotingAuthenticationTokenValidationMSFT* authenticationTokenValidation) {
        if (!authenticationTokenValidation->context) {
            return XR_ERROR_RUNTIME_FAILURE;
        }
        return reinterpret_cast<SecureConnectionCallbacks*>(authenticationTokenValidation->context)
            ->ValidateAuthenticationToken(authenticationTokenValidation);
    }

    static XrResult XRAPI_CALL
    RequestServerCertificateStaticCallback(XrRemotingServerCertificateRequestMSFT* serverCertificateRequest) {
        if (!serverCertificateRequest->context) {
            return XR_ERROR_RUNTIME_FAILURE;
        }
        return reinterpret_cast<SecureConnectionCallbacks*>(serverCertificateRequest->context)
            ->RequestServerCertificate(serverCertificateRequest);
    }
}

靜態回調函式看起來都很類似,而在上述範例中,它們只會在 內容物件上呼叫函式,而內容物件是在 或 xrRemotingSetSecureConnectionServerCallbacksMSFTxrRemotingSetSecureConnectionClientCallbacksMSFT設定。 回呼的實際實作接著會在內容對象的成員函式內完成:

class SecureConnectionCallbacks {   
    ...

private:
    // The client has to provide a token and has to validate the certificate.
    XrResult RequestAuthenticationToken(XrRemotingAuthenticationTokenRequestMSFT* authenticationTokenRequest) {
        // To provide a token fill out the authenticationTokenRequest with your token.
    }
    XrResult ValidateServerCertificate(XrRemotingServerCertificateValidationMSFT* serverCertificateValidation) {
        // Validate the certificate.
    }

    // The server has to provide a certificate and hast to validate the token.
    XrResult ValidateAuthenticationToken(XrRemotingAuthenticationTokenValidationMSFT* authenticationTokenValidation) {
        // Validate the token.
    }
    XrResult RequestServerCertificate(XrRemotingServerCertificateRequestMSFT* serverCertificateRequest) {
        // To provide a certificate fill out the serverCertificateRequest with your certificate.
    }
}

現在您可以提供和的xrRemotingSetSecureConnectionClientCallbacksMSFTxrRemotingSetSecureConnectionServerCallbacksMSFT回呼。 此外,安全連線必須透過結構或 結構上的 XrRemotingConnectInfoMSFT secureConnection 參數來啟用xrRemotingConnectMSFT,視您使用的是 或 xrRemotingListenMSFTXrRemotingListenInfoMSFT定:

...

SecureConnectionCallbacks callbackObject;

...

if (client) 
{
    XrRemotingSecureConnectionClientCallbacksMSFT clientCallbacks{static_cast<XrStructureType>(XR_TYPE_REMOTING_SECURE_CONNECTION_CLIENT_CALLBACKS_MSFT);
    clientCallbacks.context = &callbackObject;
    clientCallbacks.requestAuthenticationTokenCallback = SecureConnectionCallbacks::RequestAuthenticationTokenStaticCallback;
    clientCallbacks.validateServerCertificateCallback = SecureConnectionCallbacks::ValidateServerCertificateStaticCallback;
    clientCallbacks.performSystemValidation = true;
    CHECK_XRCMD(m_extensions.xrRemotingSetSecureConnectionClientCallbacksMSFT(m_instance.Get(), m_systemId, &clientCallbacks));
    
    ...

    connectInfo.secureConnection = true; // Enable secure connection!
    CHECK_XRCMD(m_extensions.xrRemotingConnectMSFT(m_instance.Get(), m_systemId, &connectInfo));
}

if (server) 
{
    XrRemotingSecureConnectionServerCallbacksMSFT serverCallbacks{static_cast<XrStructureType>(XR_TYPE_REMOTING_SECURE_CONNECTION_SERVER_CALLBACKS_MSFT);
    serverCallbacks.context = &callbackObject;
    serverCallbacks.requestServerCertificateCallback = SecureConnectionCallbacks::RequestServerCertificateStaticCallback;
    serverCallbacks.validateAuthenticationTokenCallback = SecureConnectionCallbacks::ValidateAuthenticationTokenStaticCallback;
    serverCallbacks.authenticationRealm = /*YourAuthenticationRealm*/;
    CHECK_XRCMD(m_extensions.xrRemotingSetSecureConnectionServerCallbacksMSFT(m_instance.Get(), m_systemId, &serverCallbacks));

    ...

    listenInfo.secureConnection = true; // Enable secure connection!
    CHECK_XRCMD(m_extensions.xrRemotingListenMSFT(m_instance.Get(), m_systemId, &listenInfo));
}

注意事項

您可以在 OpenXR 範例應用程式中找到詳細範例。

另請參閱