Partager via


CSecureChannelServer::SetCertificate

banner art

The SetCertificate method specifies the certificate and private key of the secure authenticated channel (SAC) server. The digital certificate, indicating legitimacy of media content, must be acquired from a certificate authority.

Syntax

HRESULT SetCertificate(
  DWORD  dwFlags,
  BYTE*  pbAppCert,
  DWORD  dwCertLen,
  BYTE*  pbAppPVK,
  DWORD  dwPVKLen
);

Parameters

  dwFlags

[in]  Specifies the type of certificate being passed to this method. Must be set to SAC_CERT_V1.

  pbAppCert

[in]  Pointer to the first byte of the certificate of the SAC client.

  dwCertLen

[in]  DWORD specifying the length of the certificate to which pbAppCert points.

  pbAppPVK

[in]  Pointer to the first byte of the private key of the SAC client.

  dwPVKLen

[in]  DWORD specifying the length of the private key to which pbAppPVK points.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager and service provider can return any of the following classes of error codes:

  • Standard COM error codes
  • Windows error codes converted to HRESULT values
  • Windows Media Device Manager error codes

For a complete list of possible error codes, see Error Codes.

Possible values include, but are not limited to, those in the following table.

Return code Description
S_OK The method succeeded.
E_INVALIDARG A parameter is invalid or is a NULL pointer.
E_FAIL An unspecified error occurred.

Remarks

The SetCertificate method sets the certificate to be sent to CSecureChannelClient. SetCertificate should be called immediately after creating the CSecureChannelServer object. If pbAppCert and/or pbAppPVK are NULL (or both zero) a default certificate and private key pair is used which will allow for basic functionality.

The globals pbAppCert and pbAppPVK are found in the key.cpp file.

Example Code

extern CSecureChannelServer *g_pSCWMDM;
g_pSCWMDM = new CSecureChannelServer();

// Select the cert and the associated private key into the SAC.
if (g_pSCWMDM)
{
    g_pSCWMDM->SetCertificate( SAC_CERT_V1, 
                               (BYTE*)g_abAppCert,
                               sizeof(g_abAppCert), 
                               (BYTE*)g_abPriv,
                               sizeof(g_abPriv) );
}

Requirements

Header: Include scserver.h.

Library: mssachlp.lib

See Also