windows-nt/Source/XPSP1/NT/enduser/netmeeting/srvc/rdscred.cpp
2020-09-26 16:20:57 +08:00

110 lines
3.1 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Copyright (C) 1993-1999 Microsoft Corporation. All Rights Reserved.
//
// MODULE: rdscred.cpp
//
// PURPOSE: Implements RDS credential management
//
// FUNCTIONS:
// InitT120Credentials(VOID)
//
// COMMENTS:
//
//
// AUTHOR: Claus Giloi
//
#include <precomp.h>
#include <wincrypt.h>
#include <tsecctrl.h>
#include <nmmkcert.h>
extern INmSysInfo2 * g_pNmSysInfo; // Interface to SysInfo
BOOL InitT120Credentials(VOID)
{
HCERTSTORE hStore;
PCCERT_CONTEXT pCertContext = NULL;
BOOL bRet = FALSE;
// Open the "MY" local machine certificate store. This one will be
// used when we're running as a service
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
X509_ASN_ENCODING,
0,
CERT_SYSTEM_STORE_LOCAL_MACHINE,
L"MY" );
if ( NULL != hStore )
{
#ifdef DUMPCERTS
DumpCertStore(this, "Local Machine Store MY", hStore);
#endif // DUMPCERTS
// Check the local machine store for a certificate - any!
pCertContext = CertFindCertificateInStore(hStore,
X509_ASN_ENCODING,
0,
CERT_FIND_ANY,
NULL,
NULL);
CertCloseStore( hStore, 0);
}
if ( NULL == pCertContext )
{
// Open the "_NMSTR" local machine certificate store.
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
X509_ASN_ENCODING,
0,
CERT_SYSTEM_STORE_LOCAL_MACHINE,
WSZNMSTORE );
if ( NULL != hStore )
{
#ifdef DUMPCERTS
DumpCertStore(this, "Local Machine Store _NMSTR", hStore);
#endif // DUMPCERTS
// Check the local machine store for a certificate - any!
pCertContext = CertFindCertificateInStore(hStore,
X509_ASN_ENCODING,
0,
CERT_FIND_ANY,
NULL,
NULL);
CertCloseStore( hStore, 0);
}
}
if ( NULL == pCertContext )
{
WARNING_OUT(("No service context cert found!"));
return bRet;
}
DWORD dwResult = -1;
g_pNmSysInfo->ProcessSecurityData(
TPRTCTRL_SETX509CREDENTIALS,
(DWORD_PTR)pCertContext, 0,
&dwResult);
if ( !dwResult )
{
bRet = TRUE;
}
else
{
ERROR_OUT(("InitT120Credentials - failed in T.120"));
}
CertFreeCertificateContext ( pCertContext );
return bRet;
}