Share via


Säker anslutning med Holographic Remoting och OpenXR API

När du använder OpenXR API är allt säkert anslutningsrelaterat API tillgängligt som en del av XR_MSFT_holographic_remoting OpenXR-tillägget.

Viktigt

Om du vill veta mer om Holographic Remoting OpenXR-tilläggs-API:et kan du läsa specifikationen som finns i github-lagringsplatsen Holographic Remoting Samples.

Kom ihåg att du måste implementera anpassade fjärr- och spelarappar om du vill aktivera anslutningssäkerhet. Båda de anpassade apparna behöver:

  • En certifikatprovider och en autentiseringsverifierare om appen körs som server.
  • En autentiseringsprovider och en certifikatverifierare om appen körs som klient.

OpenXR API liknar det Windows Mixed Reality API som beskrivs här. Men i stället för att implementera gränssnitt är nyckelelementen för säker anslutning med openXR-tillägget XR_MSFT_holographic_remoting följande återanrop:

  • xrRemotingRequestAuthenticationTokenCallbackMSFT, genererar eller hämtar den autentiseringstoken som ska skickas.
  • xrRemotingValidateServerCertificateCallbackMSFTvaliderar certifikatkedjan.
  • xrRemotingValidateAuthenticationTokenCallbackMSFTvaliderar klientautentiseringstoken.
  • xrRemotingRequestServerCertificateCallbackMSFT, förse serverprogrammet med certifikatet som ska användas.

Anteckning

Med Holographic Remoting är det möjligt att antingen Player eller Remote är servern beroende på dina behov (Mer information finns i Holographic Remoting Terminology). Om ditt anpassade fjärr- eller anpassat spelarprogram kan köras som klient och server måste appen tillhandahålla alla fyra återanrop.

Återanropen kan tillhandahållas till fjärrkommunikationens OpenXR-körning via xrRemotingSetSecureConnectionClientCallbacksMSFT och xrRemotingSetSecureConnectionServerCallbacksMSFT. För att göra det kan du skapa statiska funktioner för återanropen:

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);
    }
}

De statiska återanropsfunktionerna ser likadana ut och i exemplet ovan anropar de bara en funktion på kontextobjektet, som anges i xrRemotingSetSecureConnectionClientCallbacksMSFT eller xrRemotingSetSecureConnectionServerCallbacksMSFT. Den faktiska implementeringen av återanropen görs sedan i medlemsfunktionerna i kontextobjektet:

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.
    }
}

Nu kan du ange återanropen till xrRemotingSetSecureConnectionClientCallbacksMSFT och xrRemotingSetSecureConnectionServerCallbacksMSFT. Dessutom måste den säkra anslutningen aktiveras via parametern secureConnection i XrRemotingConnectInfoMSFT strukturen eller XrRemotingListenInfoMSFT strukturen beroende på om du använder xrRemotingConnectMSFT eller xrRemotingListenMSFT:

...

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));
}

Anteckning

Du hittar ett detaljerat exempel i OpenXR-exempelappen.

Se även