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.

975 lines
22 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows, Copyright (C) Microsoft Corporation, 2000
  3. File: CertificateStatus.cpp
  4. Contents: Implementation of CCertificateStatus
  5. Remarks: This object is not creatable by user directly. It can only be
  6. created via property/method of other CAPICOM objects.
  7. History: 11-15-99 dsie created
  8. ------------------------------------------------------------------------------*/
  9. #include "StdAfx.h"
  10. #include "CAPICOM.h"
  11. #include "CertificateStatus.h"
  12. #include "Chain.h"
  13. #include "OIDs.h"
  14. ///////////////
  15. //
  16. // Local
  17. //
  18. #define DEFAULT_CHECK_FLAGS ((CAPICOM_CHECK_FLAG) (CAPICOM_CHECK_SIGNATURE_VALIDITY | \
  19. CAPICOM_CHECK_TIME_VALIDITY | \
  20. CAPICOM_CHECK_TRUSTED_ROOT))
  21. ////////////////////////////////////////////////////////////////////////////////
  22. //
  23. // Exported functions.
  24. //
  25. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26. Function : CreateCertificateStatusObject
  27. Synopsis : Create an ICertificateStatus object.
  28. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  29. ICertificateStatus ** ppICertificateStatus - Pointer to pointer
  30. ICertificateStatus
  31. object.
  32. Remark :
  33. ------------------------------------------------------------------------------*/
  34. HRESULT CreateCertificateStatusObject (PCCERT_CONTEXT pCertContext,
  35. ICertificateStatus ** ppICertificateStatus)
  36. {
  37. HRESULT hr = S_OK;
  38. CComObject<CCertificateStatus> * pCCertificateStatus = NULL;
  39. DebugTrace("Entering CreateCertificateStatusObject().\n");
  40. //
  41. // Sanity check.
  42. //
  43. ATLASSERT(pCertContext);
  44. ATLASSERT(ppICertificateStatus);
  45. try
  46. {
  47. //
  48. // Create the object. Note that the ref count will still be 0
  49. // after the object is created.
  50. //
  51. if (FAILED(hr = CComObject<CCertificateStatus>::CreateInstance(&pCCertificateStatus)))
  52. {
  53. DebugTrace("Error [%#x]: CComObject<CCertificateStatus>::CreateInstance() failed.\n", hr);
  54. goto ErrorExit;
  55. }
  56. //
  57. // Initialize the object.
  58. //
  59. if (FAILED(hr = pCCertificateStatus->Init(pCertContext)))
  60. {
  61. DebugTrace("Error [%#x]: pCCertificateStatus->Init() failed.\n", hr);
  62. goto ErrorExit;
  63. }
  64. //
  65. // Return ICertificateStatus pointer to caller.
  66. //
  67. if (FAILED(hr = pCCertificateStatus->QueryInterface(ppICertificateStatus)))
  68. {
  69. DebugTrace("Error [%#x]: pCCertificateStatus->QueryInterface() failed.\n", hr);
  70. goto ErrorExit;
  71. }
  72. }
  73. catch(...)
  74. {
  75. hr = E_POINTER;
  76. DebugTrace("Exception: invalid parameter.\n");
  77. goto ErrorExit;
  78. }
  79. CommonExit:
  80. DebugTrace("Leaving CreateCertificateStatusObject().\n");
  81. return hr;
  82. ErrorExit:
  83. //
  84. // Sanity check.
  85. //
  86. ATLASSERT(FAILED(hr));
  87. //
  88. // Free resource.
  89. //
  90. if (pCCertificateStatus)
  91. {
  92. delete pCCertificateStatus;
  93. }
  94. goto CommonExit;
  95. }
  96. ////////////////////////////////////////////////////////////////////////////////
  97. //
  98. // CCertificateStatus
  99. //
  100. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  101. Function : CCertificateStatus::get_Result
  102. Synopsis : Return the overall validity result of the cert, based on the
  103. currently set check flags and EKU.
  104. Parameter: VARIANT_BOOL * pVal - Pointer to VARIANT_BOOL to receive result.
  105. Remark :
  106. ------------------------------------------------------------------------------*/
  107. STDMETHODIMP CCertificateStatus::get_Result (VARIANT_BOOL * pVal)
  108. {
  109. HRESULT hr = S_OK;
  110. CComPtr<IChain> pIChain = NULL;
  111. DebugTrace("Entering CCertificateStatus::get_Result().\n");
  112. try
  113. {
  114. //
  115. // Lock access to this object.
  116. //
  117. m_Lock.Lock();
  118. //
  119. // Check parameters.
  120. //
  121. if (NULL == pVal)
  122. {
  123. hr = E_INVALIDARG;
  124. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  125. goto ErrorExit;
  126. }
  127. //
  128. // Sanity check.
  129. //
  130. ATLASSERT(m_pCertContext);
  131. //
  132. // Build the chain and return the result.
  133. //
  134. if (FAILED(hr = ::CreateChainObject(m_pCertContext, this, NULL, pVal, &pIChain)))
  135. {
  136. DebugTrace("Error [%#x]: CreateChainObject() failed.\n", hr);
  137. goto ErrorExit;
  138. }
  139. }
  140. catch(...)
  141. {
  142. hr = E_POINTER;
  143. DebugTrace("Exception: invalid parameter.\n");
  144. goto ErrorExit;
  145. }
  146. UnlockExit:
  147. //
  148. // Unlock access to this object.
  149. //
  150. m_Lock.Unlock();
  151. DebugTrace("Leaving CCertificateStatus::get_Result().\n");
  152. return hr;
  153. ErrorExit:
  154. //
  155. // Sanity check.
  156. //
  157. ATLASSERT(FAILED(hr));
  158. ReportError(hr);
  159. goto UnlockExit;
  160. }
  161. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  162. Function : CCertificateStatus::get_CheckFlag
  163. Synopsis : Return the currently set validity check flag.
  164. Parameter: CAPICOM_CHECK_FLAG * pVal - Pointer to CAPICOM_CHECK_FLAG to
  165. receive check flag.
  166. Remark :
  167. ------------------------------------------------------------------------------*/
  168. STDMETHODIMP CCertificateStatus::get_CheckFlag (CAPICOM_CHECK_FLAG * pVal)
  169. {
  170. HRESULT hr = S_OK;
  171. DebugTrace("Entering CCertificateStatus::get_CheckFlag().\n");
  172. try
  173. {
  174. //
  175. // Lock access to this object.
  176. //
  177. m_Lock.Lock();
  178. //
  179. // Check parameters.
  180. //
  181. if (NULL == pVal)
  182. {
  183. hr = E_INVALIDARG;
  184. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  185. goto ErrorExit;
  186. }
  187. //
  188. // Return flag to user.
  189. //
  190. *pVal = m_CheckFlag;
  191. }
  192. catch(...)
  193. {
  194. hr = E_POINTER;
  195. DebugTrace("Exception: invalid parameter.\n");
  196. goto ErrorExit;
  197. }
  198. UnlockExit:
  199. //
  200. // Unlock access to this object.
  201. //
  202. m_Lock.Unlock();
  203. DebugTrace("Leaving CCertificateStatus::get_CheckFlag().\n");
  204. return hr;
  205. ErrorExit:
  206. //
  207. // Sanity check.
  208. //
  209. ATLASSERT(FAILED(hr));
  210. ReportError(hr);
  211. goto UnlockExit;
  212. }
  213. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  214. Function : CCertificateStatus::put_CheckFlag
  215. Synopsis : Set validity check flag.
  216. Parameter: CAPICOM_CHECK_FLAG newVal - Check flag.
  217. Remark : Note that CHECK_ONLINE_REVOCATION_STATUS and
  218. CHECK_OFFLINE_REVOCATION_STATUS is mutually exclusive.
  219. ------------------------------------------------------------------------------*/
  220. STDMETHODIMP CCertificateStatus::put_CheckFlag (CAPICOM_CHECK_FLAG newVal)
  221. {
  222. HRESULT hr = S_OK;
  223. DebugTrace("Entering CCertificateStatus::put_CheckFlag().\n");
  224. //
  225. // Lock access to this object.
  226. //
  227. m_Lock.Lock();
  228. //
  229. // Make sure flag is valid (maximum is CAPICOM_CHECK_OFFLINE_ALL).
  230. //
  231. if ((newVal & CAPICOM_CHECK_FLAG_LO_MASK) > CAPICOM_CHECK_OFFLINE_ALL)
  232. {
  233. hr = E_INVALIDARG;
  234. DebugTrace("Error [%#x]: invalid check flag (%#x).\n", hr, newVal);
  235. goto ErrorExit;
  236. }
  237. //
  238. // Store check flag.
  239. //
  240. m_CheckFlag = newVal;
  241. UnlockExit:
  242. //
  243. // Unlock access to this object.
  244. //
  245. m_Lock.Unlock();
  246. DebugTrace("Leaving CCertificateStatus::put_CheckFlag().\n");
  247. return hr;
  248. ErrorExit:
  249. //
  250. // Sanity check.
  251. //
  252. ATLASSERT(FAILED(hr));
  253. ReportError(hr);
  254. goto UnlockExit;
  255. }
  256. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  257. Function : CCertificateStatus::EKU
  258. Synopsis : Return the EKU object.
  259. Parameter: IEKU ** pVal - Pointer to pointer to IEKU to receive the
  260. interface pointer.
  261. Remark :
  262. ------------------------------------------------------------------------------*/
  263. STDMETHODIMP CCertificateStatus::EKU (IEKU ** pVal)
  264. {
  265. HRESULT hr = S_OK;
  266. DebugTrace("Entering CCertificateStatus::EKU().\n");
  267. try
  268. {
  269. //
  270. // Lock access to this object.
  271. //
  272. m_Lock.Lock();
  273. //
  274. // Check parameters.
  275. //
  276. if (NULL == pVal)
  277. {
  278. hr = E_INVALIDARG;
  279. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  280. goto ErrorExit;
  281. }
  282. //
  283. // Sanity check.
  284. //
  285. ATLASSERT(m_pIEKU);
  286. //
  287. // Return interface pointer to user.
  288. //
  289. if (FAILED(hr = m_pIEKU->QueryInterface(pVal)))
  290. {
  291. DebugTrace("Error [%#x]: m_pIEKU->QueryInterface() failed.\n", hr);
  292. goto ErrorExit;
  293. }
  294. }
  295. catch(...)
  296. {
  297. hr = E_POINTER;
  298. DebugTrace("Exception: invalid parameter.\n");
  299. goto ErrorExit;
  300. }
  301. UnlockExit:
  302. //
  303. // Unlock access to this object.
  304. //
  305. m_Lock.Unlock();
  306. DebugTrace("Leaving CCertificateStatus::EKU().\n");
  307. return hr;
  308. ErrorExit:
  309. //
  310. // Sanity check.
  311. //
  312. ATLASSERT(FAILED(hr));
  313. ReportError(hr);
  314. goto UnlockExit;
  315. }
  316. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  317. Function : CCertificateStatus::get_VerificationTime
  318. Synopsis : Return the verification time.
  319. Parameter: DATE * pVal - Pointer to DATE to receive the value.
  320. Remark :
  321. ------------------------------------------------------------------------------*/
  322. STDMETHODIMP CCertificateStatus::get_VerificationTime (DATE * pVal)
  323. {
  324. HRESULT hr = S_OK;
  325. SYSTEMTIME st = {0};
  326. DebugTrace("Entering CCertificateStatus::get_VerificationTime().\n");
  327. try
  328. {
  329. //
  330. // Lock access to this object.
  331. //
  332. m_Lock.Lock();
  333. //
  334. // Make sure paremeters are valid.
  335. //
  336. if (NULL == pVal)
  337. {
  338. hr = E_INVALIDARG;
  339. DebugTrace("Error [%#x]: Paremeter pVal is NULL.\n", hr);
  340. goto ErrorExit;
  341. }
  342. //
  343. // If the time was never explicit set by user, return the current time.
  344. //
  345. if ((DATE) 0 == m_VerificationTime)
  346. {
  347. ::GetLocalTime(&st);
  348. //
  349. // Convert to DATE.
  350. //
  351. if (0 == ::SystemTimeToVariantTime(&st, pVal))
  352. {
  353. hr = E_INVALIDARG;
  354. DebugTrace("Error [%#x]: SystemTimeToVariantTime() failed.\n", hr);
  355. goto ErrorExit;
  356. }
  357. }
  358. else
  359. {
  360. //
  361. // Return previously set verification time to caller.
  362. //
  363. *pVal = m_VerificationTime;
  364. }
  365. }
  366. catch(...)
  367. {
  368. hr = E_POINTER;
  369. DebugTrace("Exception: invalid parameter.\n");
  370. goto ErrorExit;
  371. }
  372. UnlockExit:
  373. //
  374. // Unlock access to this object.
  375. //
  376. m_Lock.Unlock();
  377. DebugTrace("Leaving CCertificateStatus::get_VerificationTime().\n");
  378. return hr;
  379. ErrorExit:
  380. //
  381. // Sanity check.
  382. //
  383. ATLASSERT(FAILED(hr));
  384. ReportError(hr);
  385. goto UnlockExit;
  386. }
  387. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  388. Function : CCertificateStatus::put_VerificationTime
  389. Synopsis : Set the verification time.
  390. Parameter: DATE newVal - New DATE value.
  391. Remark :
  392. ------------------------------------------------------------------------------*/
  393. STDMETHODIMP CCertificateStatus::put_VerificationTime (DATE newVal)
  394. {
  395. HRESULT hr = S_OK;
  396. DebugTrace("Entering CCertificateStatus::put_VerificationTime().\n");
  397. try
  398. {
  399. //
  400. // Lock access to this object.
  401. //
  402. m_Lock.Lock();
  403. //
  404. // Update verification time.
  405. //
  406. m_VerificationTime = newVal;
  407. }
  408. catch(...)
  409. {
  410. hr = E_POINTER;
  411. DebugTrace("Exception: invalid parameter.\n");
  412. goto ErrorExit;
  413. }
  414. UnlockExit:
  415. //
  416. // Unlock access to this object.
  417. //
  418. m_Lock.Unlock();
  419. DebugTrace("Leaving CCertificateStatus::put_VerificationTime().\n");
  420. return hr;
  421. ErrorExit:
  422. //
  423. // Sanity check.
  424. //
  425. ATLASSERT(FAILED(hr));
  426. ReportError(hr);
  427. goto UnlockExit;
  428. }
  429. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  430. Function : CCertificateStatus::get_UrlRetrievalTimeout
  431. Synopsis : Get the URL retrieval timeout value in seconds.
  432. Parameter: long * pVal - Pointer to long to receive the value.
  433. Remark :
  434. ------------------------------------------------------------------------------*/
  435. STDMETHODIMP CCertificateStatus::get_UrlRetrievalTimeout (long * pVal)
  436. {
  437. HRESULT hr = S_OK;
  438. DebugTrace("Entering CCertificateStatus::get_UrlRetrievalTimeout().\n");
  439. try
  440. {
  441. //
  442. // Lock access to this object.
  443. //
  444. m_Lock.Lock();
  445. //
  446. // Make sure paremeters are valid.
  447. //
  448. if (NULL == pVal)
  449. {
  450. hr = E_INVALIDARG;
  451. DebugTrace("Error [%#x]: Paremeter pVal is NULL.\n", hr);
  452. goto ErrorExit;
  453. }
  454. //
  455. // Return previously set URL retrieval timeout to caller.
  456. //
  457. *pVal = m_dwUrlRetrievalTimeout;
  458. }
  459. catch(...)
  460. {
  461. hr = E_POINTER;
  462. DebugTrace("Exception: invalid parameter.\n");
  463. goto ErrorExit;
  464. }
  465. UnlockExit:
  466. //
  467. // Unlock access to this object.
  468. //
  469. m_Lock.Unlock();
  470. DebugTrace("Leaving CCertificateStatus::get_UrlRetrievalTimeout().\n");
  471. return hr;
  472. ErrorExit:
  473. //
  474. // Sanity check.
  475. //
  476. ATLASSERT(FAILED(hr));
  477. ReportError(hr);
  478. goto UnlockExit;
  479. }
  480. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  481. Function : CCertificateStatus::put_UrlRetrievalTimeout
  482. Synopsis : Set the URL retrieval timeout value in seconds.
  483. Parameter: long newVal - New URL retrieval timeout value..
  484. Remark :
  485. ------------------------------------------------------------------------------*/
  486. STDMETHODIMP CCertificateStatus::put_UrlRetrievalTimeout (long newVal)
  487. {
  488. HRESULT hr = S_OK;
  489. DebugTrace("Entering CCertificateStatus::put_UrlRetrievalTimeout().\n");
  490. try
  491. {
  492. //
  493. // Lock access to this object.
  494. //
  495. m_Lock.Lock();
  496. //
  497. // Make sure paremeters are valid.
  498. //
  499. if (CAPICOM_MAX_URL_RETRIEVAL_TIMEOUT < (DWORD) newVal)
  500. {
  501. hr = E_INVALIDARG;
  502. DebugTrace("Error [%#x]: newVal (%#x) is greater than max retrieval timeout allowed.\n",
  503. hr, newVal);
  504. goto ErrorExit;
  505. }
  506. //
  507. // Update URL retrieval timeout.
  508. //
  509. m_dwUrlRetrievalTimeout = newVal;
  510. }
  511. catch(...)
  512. {
  513. hr = E_POINTER;
  514. DebugTrace("Exception: invalid parameter.\n");
  515. goto ErrorExit;
  516. }
  517. UnlockExit:
  518. //
  519. // Unlock access to this object.
  520. //
  521. m_Lock.Unlock();
  522. DebugTrace("Leaving CCertificateStatus::put_UrlRetrievalTimeout().\n");
  523. return hr;
  524. ErrorExit:
  525. //
  526. // Sanity check.
  527. //
  528. ATLASSERT(FAILED(hr));
  529. ReportError(hr);
  530. goto UnlockExit;
  531. }
  532. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  533. Function : CCertificateStatus::CertificatePolicies
  534. Synopsis : Return the certificate policies OIDs collection for which this
  535. chain is valid.
  536. Parameter: IOID ** pVal - Pointer to pointer to IOIDs to receive the
  537. interface pointer.
  538. Remark :
  539. ------------------------------------------------------------------------------*/
  540. STDMETHODIMP CCertificateStatus::CertificatePolicies (IOIDs ** pVal)
  541. {
  542. HRESULT hr = S_OK;
  543. DebugTrace("Entering CCertificateStatus::CertificatePolicies().\n");
  544. try
  545. {
  546. //
  547. // Lock access to this object.
  548. //
  549. m_Lock.Lock();
  550. //
  551. // Check parameters.
  552. //
  553. if (NULL == pVal)
  554. {
  555. hr = E_INVALIDARG;
  556. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  557. goto ErrorExit;
  558. }
  559. //
  560. // Sanity check.
  561. //
  562. ATLASSERT(m_pICertificatePolicies);
  563. //
  564. // Return interface pointer to user.
  565. //
  566. if (FAILED(hr = m_pICertificatePolicies->QueryInterface(pVal)))
  567. {
  568. DebugTrace("Error [%#x]: m_pICertificatePolicies->QueryInterface() failed.\n", hr);
  569. goto ErrorExit;
  570. }
  571. }
  572. catch(...)
  573. {
  574. hr = E_POINTER;
  575. DebugTrace("Exception: invalid parameter.\n");
  576. goto ErrorExit;
  577. }
  578. UnlockExit:
  579. //
  580. // Unlock access to this object.
  581. //
  582. m_Lock.Unlock();
  583. DebugTrace("Leaving CCertificateStatus::CertificatePolicies().\n");
  584. return hr;
  585. ErrorExit:
  586. //
  587. // Sanity check.
  588. //
  589. ATLASSERT(FAILED(hr));
  590. ReportError(hr);
  591. goto UnlockExit;
  592. }
  593. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  594. Function : CCertificateStatus::ApplicationPolicies
  595. Synopsis : Return the application policies OIDs collection for which this
  596. chain is valid.
  597. Parameter: IOID ** pVal - Pointer to pointer to IOIDs to receive the
  598. interface pointer.
  599. Remark :
  600. ------------------------------------------------------------------------------*/
  601. STDMETHODIMP CCertificateStatus::ApplicationPolicies (IOIDs ** pVal)
  602. {
  603. HRESULT hr = S_OK;
  604. DebugTrace("Entering CCertificateStatus::ApplicationPolicies().\n");
  605. try
  606. {
  607. //
  608. // Lock access to this object.
  609. //
  610. m_Lock.Lock();
  611. //
  612. // Check parameters.
  613. //
  614. if (NULL == pVal)
  615. {
  616. hr = E_INVALIDARG;
  617. DebugTrace("Error [%#x]: Parameter pVal is NULL.\n", hr);
  618. goto ErrorExit;
  619. }
  620. //
  621. // Sanity check.
  622. //
  623. ATLASSERT(m_pIApplicationPolicies);
  624. //
  625. // Return interface pointer to user.
  626. //
  627. if (FAILED(hr = m_pIApplicationPolicies->QueryInterface(pVal)))
  628. {
  629. DebugTrace("Error [%#x]: m_pIApplicationPolicies->QueryInterface() failed.\n", hr);
  630. goto ErrorExit;
  631. }
  632. }
  633. catch(...)
  634. {
  635. hr = E_POINTER;
  636. DebugTrace("Exception: invalid parameter.\n");
  637. goto ErrorExit;
  638. }
  639. UnlockExit:
  640. //
  641. // Unlock access to this object.
  642. //
  643. m_Lock.Unlock();
  644. DebugTrace("Leaving CCertificateStatus::ApplicationPolicies().\n");
  645. return hr;
  646. ErrorExit:
  647. //
  648. // Sanity check.
  649. //
  650. ATLASSERT(FAILED(hr));
  651. ReportError(hr);
  652. goto UnlockExit;
  653. }
  654. ////////////////////////////////////////////////////////////////////////////////
  655. //
  656. // Private methods.
  657. //
  658. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  659. Function : CCertificateStatus::Init
  660. Synopsis : Initialize the object.
  661. Parameter: PCCERT_CONTEXT pCertContext - Pointer to CERT_CONTEXT.
  662. Remark : This method is not part of the COM interface (it is a normal C++
  663. member function). We need it to initialize the object created
  664. internally by us with CERT_CONTEXT.
  665. Since it is only a normal C++ member function, this function can
  666. only be called from a C++ class pointer, not an interface pointer.
  667. ------------------------------------------------------------------------------*/
  668. STDMETHODIMP CCertificateStatus::Init (PCCERT_CONTEXT pCertContext)
  669. {
  670. HRESULT hr = S_OK;
  671. CERT_ENHKEY_USAGE eku = {0, NULL};
  672. DebugTrace("Entering CCertificateStatus::Init().\n");
  673. //
  674. // Sanity check.
  675. //
  676. ATLASSERT(pCertContext);
  677. //
  678. // Set default check flags.
  679. //
  680. m_CheckFlag = DEFAULT_CHECK_FLAGS;
  681. //
  682. // Create the EKU object (default no EKU check).
  683. //
  684. if (FAILED(hr = ::CreateEKUObject(NULL, &m_pIEKU)))
  685. {
  686. DebugTrace("Error [%#x]: CreateEKUObject() failed.\n", hr);
  687. goto CommonExit;
  688. }
  689. //
  690. // Create the OIDs collection for certificate policies.
  691. //
  692. if (FAILED(hr = ::CreateOIDsObject(&eku, TRUE, &m_pICertificatePolicies)))
  693. {
  694. DebugTrace("Error [%#x]: CreateOIDsObject() failed.\n", hr);
  695. goto CommonExit;
  696. }
  697. //
  698. // Create the OIDs collection for application policies.
  699. //
  700. if (FAILED(hr = ::CreateOIDsObject(&eku, FALSE, &m_pIApplicationPolicies)))
  701. {
  702. DebugTrace("Error [%#x]: CreateOIDsObject() failed.\n", hr);
  703. goto CommonExit;
  704. }
  705. //
  706. // Save cert context.
  707. //
  708. if (!(m_pCertContext = ::CertDuplicateCertificateContext(pCertContext)))
  709. {
  710. hr = HRESULT_FROM_WIN32(::GetLastError());
  711. DebugTrace("Error [%#x]: CertDuplicateCertificateContext() failed.\n", hr);
  712. }
  713. m_VerificationTime = (DATE) 0;
  714. m_dwUrlRetrievalTimeout = 0;
  715. CommonExit:
  716. DebugTrace("Leaving CCertificateStatus::Init().\n");
  717. return hr;
  718. }