Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
1.9 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1998
  5. //
  6. // File: cert.c
  7. //
  8. // Contents: Centralized server certificate management
  9. //
  10. // History: 02-09-00 RobLeit Created
  11. //
  12. //-----------------------------------------------------------------------------
  13. #include <windows.h>
  14. #include "license.h"
  15. #include "lscsp.h"
  16. ///////////////////////////////////////////////////////////////////////////////
  17. LICENSE_STATUS
  18. TLSGetTSCertificate(
  19. CERT_TYPE CertType,
  20. LPBYTE *ppbCertificate,
  21. LPDWORD pcbCertificate)
  22. {
  23. LICENSE_STATUS Status;
  24. DWORD dwSize;
  25. LSCSPINFO CspData;
  26. if( CERT_TYPE_PROPRIETORY == CertType )
  27. {
  28. CspData = LsCspInfo_Certificate;
  29. }
  30. else if( CERT_TYPE_X509 == CertType )
  31. {
  32. CspData = LsCspInfo_X509Certificate;
  33. }
  34. else
  35. {
  36. return( LICENSE_STATUS_NO_CERTIFICATE );
  37. }
  38. Status = LsCsp_GetServerData( CspData, NULL, &dwSize );
  39. if( LICENSE_STATUS_OK != Status )
  40. {
  41. return( Status );
  42. }
  43. if( 0 == dwSize )
  44. {
  45. return( LICENSE_STATUS_INVALID_INPUT );
  46. }
  47. *ppbCertificate = LocalAlloc( LMEM_ZEROINIT, dwSize );
  48. if( NULL == *ppbCertificate )
  49. {
  50. return( LICENSE_STATUS_OUT_OF_MEMORY );
  51. }
  52. Status = LsCsp_GetServerData( CspData, *ppbCertificate, &dwSize );
  53. if( LICENSE_STATUS_OK != Status )
  54. {
  55. LocalFree( *ppbCertificate );
  56. return( Status );
  57. }
  58. *pcbCertificate = dwSize;
  59. return( LICENSE_STATUS_OK );
  60. }
  61. LICENSE_STATUS
  62. TLSFreeTSCertificate(
  63. LPBYTE pbCertificate)
  64. {
  65. if (NULL != pbCertificate)
  66. {
  67. LocalFree(pbCertificate);
  68. return LICENSE_STATUS_OK;
  69. }
  70. else
  71. {
  72. return LICENSE_STATUS_INVALID_INPUT;
  73. }
  74. }