Source code of Windows XP (NT5)
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.

2389 lines
64 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 2000
  5. //
  6. // File: certca.h
  7. //
  8. // Contents: Definition of the CA Info API
  9. //
  10. // History: 12-dec-97 petesk created
  11. // 28-Jan-2000 xiaohs updated
  12. //
  13. //---------------------------------------------------------------------------
  14. #ifndef __CERTCA_H__
  15. #define __CERTCA_H__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. #ifdef __cplusplus
  20. extern "C"{
  21. #endif
  22. #include <wincrypt.h>
  23. #if !defined(_CERTCLI_)
  24. #define CERTCLIAPI DECLSPEC_IMPORT
  25. #else
  26. #define CERTCLIAPI
  27. #endif
  28. typedef VOID * HCAINFO;
  29. typedef VOID * HCERTTYPE;
  30. typedef VOID * HCERTTYPEQUERY;
  31. //*****************************************************************************
  32. //
  33. // Flags used by CAFindByName, CAFindByCertType, CAFindByIssuerDN and
  34. // CAEnumFirstCA
  35. //
  36. // See comments on each API for a list of applicable flags
  37. //
  38. //*****************************************************************************
  39. //the wszScope supplied is a domain location in the DNS format
  40. #define CA_FLAG_SCOPE_DNS 0x00000001
  41. // include untrusted CA
  42. #define CA_FIND_INCLUDE_UNTRUSTED 0x00000010
  43. // running as local system. Used to verify CA certificate chain
  44. #define CA_FIND_LOCAL_SYSTEM 0x00000020
  45. // Include CAs that do not support templates
  46. #define CA_FIND_INCLUDE_NON_TEMPLATE_CA 0x00000040
  47. // The value passed in for scope is the LDAP binding handle to use during finds
  48. #define CA_FLAG_SCOPE_IS_LDAP_HANDLE 0x00000800
  49. //*****************************************************************************
  50. //
  51. // Flags used by CAEnumCertTypesForCA, CAEnumCertTypes,
  52. // CAFindCertTypeByName, CAEnumCertTypesForCAEx, and CAEnumCertTypesEx.
  53. //
  54. // See comments on each API for a list of applicable flags
  55. //
  56. //*****************************************************************************
  57. // Instead of enumerating the certificate types supported by the CA, enumerate
  58. // ALL certificate types which the CA may choose to support.
  59. #define CA_FLAG_ENUM_ALL_TYPES 0x00000004
  60. // running as local system. Used to find cached information in the registry.
  61. #define CT_FIND_LOCAL_SYSTEM CA_FIND_LOCAL_SYSTEM
  62. // Return machine types, as opposed to user types
  63. #define CT_ENUM_MACHINE_TYPES 0x00000040
  64. // Return user types, as opposed to user types
  65. #define CT_ENUM_USER_TYPES 0x00000080
  66. // Find the certificate type by its OID, instead of its name
  67. #define CT_FIND_BY_OID 0x00000200
  68. // Disable the cache expiration check
  69. #define CT_FLAG_NO_CACHE_LOOKUP 0x00000400
  70. // The value passed in for scope is the LDAP binding handle to use during finds
  71. #define CT_FLAG_SCOPE_IS_LDAP_HANDLE CA_FLAG_SCOPE_IS_LDAP_HANDLE
  72. //*****************************************************************************
  73. //
  74. // Certification Authority manipulation APIs
  75. //
  76. //*****************************************************************************
  77. // CAFindByName
  78. //
  79. // Given the Name of a CA (CN), find the CA within the given domain and return
  80. // the given phCAInfo structure.
  81. //
  82. // wszCAName - Common name of the CA
  83. //
  84. // wszScope - The distinguished name (DN) of the entry at which to start
  85. // the search. Equivalent of the "base" parameter of the
  86. // ldap_search_sxxx APIs.
  87. // NULL if use the current domain.
  88. // If CA_FLAG_SCOPE_DNS is set, wszScope is in the DNS format.
  89. // If CA_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  90. // binding handle to use during finds.
  91. //
  92. // dwFlags - Oring of the following flags:
  93. // CA_FLAG_SCOPE_DNS
  94. // CA_FIND_INCLUDE_UNTRUSTED
  95. // CA_FIND_LOCAL_SYSTEM
  96. // CA_FIND_INCLUDE_NON_TEMPLATE_CA
  97. // CA_FLAG_SCOPE_IS_LDAP_HANDLE
  98. //
  99. // phCAInfo - Handle to the returned CA.
  100. //
  101. // Return: Returns S_OK if CA was found.
  102. //
  103. CERTCLIAPI
  104. HRESULT
  105. WINAPI
  106. CAFindByName(
  107. IN LPCWSTR wszCAName,
  108. IN LPCWSTR wszScope,
  109. IN DWORD dwFlags,
  110. OUT HCAINFO * phCAInfo
  111. );
  112. //
  113. // CAFindByCertType
  114. //
  115. // Given the Name of a Cert Type, find all the CAs within the given domain and
  116. // return the given phCAInfo structure.
  117. //
  118. // wszCertType - Common Name of the cert type
  119. //
  120. // wszScope - The distinguished name (DN) of the entry at which to start
  121. // the search. Equivalent of the "base" parameter of the
  122. // ldap_search_sxxx APIs.
  123. // NULL if use the current domain.
  124. // If CA_FLAG_SCOPE_DNS is set, wszScope is in the DNS format.
  125. // If CA_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  126. // binding handle to use during finds.
  127. //
  128. // dwFlags - Oring of the following flags:
  129. // CA_FLAG_SCOPE_DNS
  130. // CA_FIND_INCLUDE_UNTRUSTED
  131. // CA_FIND_LOCAL_SYSTEM
  132. // CA_FIND_INCLUDE_NON_TEMPLATE_CA
  133. // CA_FLAG_SCOPE_IS_LDAP_HANDLE
  134. //
  135. // phCAInfo - Handle to enumeration of CAs supporting the specified cert
  136. // type.
  137. //
  138. // Return: Returns S_OK on success.
  139. // Will return S_OK if none are found.
  140. // *phCAInfo will contain NULL
  141. //
  142. CERTCLIAPI
  143. HRESULT
  144. WINAPI
  145. CAFindByCertType(
  146. IN LPCWSTR wszCertType,
  147. IN LPCWSTR wszScope,
  148. IN DWORD dwFlags,
  149. OUT HCAINFO * phCAInfo
  150. );
  151. //
  152. // CAFindByIssuerDN
  153. // Given the DN of a CA, find the CA within the given domain and return the
  154. // given phCAInfo handle.
  155. //
  156. // pIssuerDN - a cert name blob from the CA's certificate.
  157. //
  158. // wszScope - The distinguished name (DN) of the entry at which to start
  159. // the search. Equivalent of the "base" parameter of the
  160. // ldap_search_sxxx APIs.
  161. // NULL if use the current domain.
  162. // If CA_FLAG_SCOPE_DNS is set, wszScope is in the DNS format.
  163. // If CA_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  164. // binding handle to use during finds.
  165. //
  166. // dwFlags - Oring of the following flags:
  167. // CA_FLAG_SCOPE_DNS
  168. // CA_FIND_INCLUDE_UNTRUSTED
  169. // CA_FIND_LOCAL_SYSTEM
  170. // CA_FIND_INCLUDE_NON_TEMPLATE_CA
  171. // CA_FLAG_SCOPE_IS_LDAP_HANDLE
  172. //
  173. //
  174. // Return: Returns S_OK if CA was found.
  175. //
  176. CERTCLIAPI
  177. HRESULT
  178. WINAPI
  179. CAFindByIssuerDN(
  180. IN CERT_NAME_BLOB const * pIssuerDN,
  181. IN LPCWSTR wszScope,
  182. IN DWORD dwFlags,
  183. OUT HCAINFO * phCAInfo
  184. );
  185. //
  186. // CAEnumFirstCA
  187. // Enumerate the CAs in a scope
  188. //
  189. // wszScope - The distinguished name (DN) of the entry at which to start
  190. // the search. Equivalent of the "base" parameter of the
  191. // ldap_search_sxxx APIs.
  192. // NULL if use the current domain.
  193. // If CA_FLAG_SCOPE_DNS is set, wszScope is in the DNS format.
  194. // If CA_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  195. // binding handle to use during finds.
  196. //
  197. // dwFlags - Oring of the following flags:
  198. // CA_FLAG_SCOPE_DNS
  199. // CA_FIND_INCLUDE_UNTRUSTED
  200. // CA_FIND_LOCAL_SYSTEM
  201. // CA_FIND_INCLUDE_NON_TEMPLATE_CA
  202. // CA_FLAG_SCOPE_IS_LDAP_HANDLE
  203. //
  204. // phCAInfo - Handle to enumeration of CAs supporting the specified cert
  205. // type.
  206. //
  207. //
  208. // Return: Returns S_OK on success.
  209. // Will return S_OK if none are found.
  210. // *phCAInfo will contain NULL
  211. //
  212. CERTCLIAPI
  213. HRESULT
  214. WINAPI
  215. CAEnumFirstCA(
  216. IN LPCWSTR wszScope,
  217. IN DWORD dwFlags,
  218. OUT HCAINFO * phCAInfo
  219. );
  220. //
  221. // CAEnumNextCA
  222. // Find the Next CA in an enumeration.
  223. //
  224. // hPrevCA - Current CA in an enumeration.
  225. //
  226. // phCAInfo - next CA in an enumeration.
  227. //
  228. // Return: Returns S_OK on success.
  229. // Will return S_OK if none are found.
  230. // *phCAInfo will contain NULL
  231. //
  232. CERTCLIAPI
  233. HRESULT
  234. WINAPI
  235. CAEnumNextCA(
  236. IN HCAINFO hPrevCA,
  237. OUT HCAINFO * phCAInfo
  238. );
  239. //
  240. // CACreateNewCA
  241. // Create a new CA of given name.
  242. //
  243. // wszCAName - Common name of the CA
  244. //
  245. // wszScope - The distinguished name (DN) of the entry at which to create
  246. // the CA object. We will add the "CN=...,..,CN=Services" after
  247. // the DN.
  248. // NULL if use the current domain.
  249. // If CA_FLAG_SCOPE_DNS is set, wszScope is in the DNS format.
  250. //
  251. // dwFlags - Oring of the following flags:
  252. // CA_FLAG_SCOPE_DNS
  253. //
  254. // phCAInfo - Handle to the returned CA.
  255. //
  256. // See above for other parameter definitions
  257. //
  258. // Return: Returns S_OK if CA was created.
  259. //
  260. // NOTE: Actual updates to the CA object may not occur until CAUpdateCA is
  261. // called. In order to successfully update a created CA, the
  262. // Certificate must be set, as well as the Certificate Types property.
  263. //
  264. CERTCLIAPI
  265. HRESULT
  266. WINAPI
  267. CACreateNewCA(
  268. IN LPCWSTR wszCAName,
  269. IN LPCWSTR wszScope,
  270. IN DWORD dwFlags,
  271. OUT HCAINFO * phCAInfo
  272. );
  273. //
  274. // CAUpdateCA
  275. // Write any changes made to the CA back to the CA object.
  276. //
  277. // hCAInfo - Handle to an open CA object.
  278. //
  279. CERTCLIAPI
  280. HRESULT
  281. WINAPI
  282. CAUpdateCA(
  283. IN HCAINFO hCAInfo
  284. );
  285. //
  286. // CADeleteCA
  287. // Delete the CA object from the DS.
  288. //
  289. // hCAInfo - Handle to an open CA object.
  290. //
  291. CERTCLIAPI
  292. HRESULT
  293. WINAPI
  294. CADeleteCA(
  295. IN HCAINFO hCAInfo
  296. );
  297. //
  298. // CACountCAs
  299. // return the number of CAs in this enumeration
  300. //
  301. CERTCLIAPI
  302. DWORD
  303. WINAPI
  304. CACountCAs(
  305. IN HCAINFO hCAInfo
  306. );
  307. //
  308. // CAGetDN
  309. // returns the DN of the associated DS object
  310. //
  311. CERTCLIAPI
  312. LPCWSTR
  313. WINAPI
  314. CAGetDN(
  315. IN HCAINFO hCAInfo
  316. );
  317. //
  318. // CACloseCA
  319. // Close an open CA handle
  320. //
  321. // hCAInfo - Handle to an open CA object.
  322. //
  323. CERTCLIAPI
  324. HRESULT
  325. WINAPI
  326. CACloseCA(
  327. IN HCAINFO hCA
  328. );
  329. //
  330. // CAGetCAProperty - Given a property name, retrieve a
  331. // property from a CAInfo.
  332. //
  333. // hCAInfo - Handle to an open CA object.
  334. //
  335. // wszPropertyName - Name of the CA property
  336. //
  337. // pawszPropertyValue - A pointer into which an array of WCHAR strings is
  338. // written, containing the values of the property. The
  339. // last element of the array points to NULL.
  340. // If the property is single valued, then the array
  341. // returned contains 2 elements, the first pointing to
  342. // the value, the second pointing to NULL. This pointer
  343. // must be freed by CAFreeCAProperty.
  344. //
  345. // Returns - S_OK on success.
  346. //
  347. CERTCLIAPI
  348. HRESULT
  349. WINAPI
  350. CAGetCAProperty(
  351. IN HCAINFO hCAInfo,
  352. IN LPCWSTR wszPropertyName,
  353. OUT LPWSTR ** pawszPropertyValue
  354. );
  355. //
  356. // CAFreeProperty
  357. // Frees a previously retrieved property value.
  358. //
  359. // hCAInfo - Handle to an open CA object.
  360. //
  361. // awszPropertyValue - pointer to the previously retrieved property value.
  362. //
  363. CERTCLIAPI
  364. HRESULT
  365. WINAPI
  366. CAFreeCAProperty(
  367. IN HCAINFO hCAInfo,
  368. LPWSTR * awszPropertyValue
  369. );
  370. //
  371. // CASetCAProperty - Given a property name, set its value.
  372. //
  373. // hCAInfo - Handle to an open CA object.
  374. //
  375. // wszPropertyName - Name of the CA property
  376. //
  377. // awszPropertyValue - An array of values to set for this property. The
  378. // last element of this - array should be NULL.
  379. // For single valued properties, the values beyond the
  380. // first will be ignored upon update.
  381. //
  382. // Returns - S_OK on success.
  383. //
  384. CERTCLIAPI
  385. HRESULT
  386. WINAPI
  387. CASetCAProperty(
  388. IN HCAINFO hCAInfo,
  389. IN LPCWSTR wszPropertyName,
  390. IN LPWSTR * awszPropertyValue
  391. );
  392. //*****************************************************************************
  393. ///
  394. // CA Properties
  395. //
  396. //*****************************************************************************
  397. // simple name of the CA
  398. #define CA_PROP_NAME L"cn"
  399. // display name of the CA object
  400. #define CA_PROP_DISPLAY_NAME L"displayName"
  401. // dns name of the machine
  402. #define CA_PROP_DNSNAME L"dNSHostName"
  403. // DS Location of CA object (DN)
  404. #define CA_PROP_DSLOCATION L"distinguishedName"
  405. // Supported cert types
  406. #define CA_PROP_CERT_TYPES L"certificateTemplates"
  407. // Supported signature algs
  408. #define CA_PROP_SIGNATURE_ALGS L"signatureAlgorithms"
  409. // DN of the CA's cert
  410. #define CA_PROP_CERT_DN L"cACertificateDN"
  411. #define CA_PROP_ENROLLMENT_PROVIDERS L"enrollmentProviders"
  412. // CA's description
  413. #define CA_PROP_DESCRIPTION L"Description"
  414. //
  415. // CAGetCACertificate - Return the current certificate for
  416. // this CA.
  417. //
  418. // hCAInfo - Handle to an open CA object.
  419. //
  420. // ppCert - Pointer into which a certificate is written. This
  421. // certificate must be freed via CertFreeCertificateContext.
  422. // This value will be NULL if no certificate is set for this CA.
  423. //
  424. CERTCLIAPI
  425. HRESULT
  426. WINAPI
  427. CAGetCAFlags(
  428. IN HCAINFO hCAInfo,
  429. OUT DWORD *pdwFlags
  430. );
  431. //*****************************************************************************
  432. //
  433. // CA Flags
  434. //
  435. //*****************************************************************************
  436. // The CA supports certificate templates
  437. #define CA_FLAG_NO_TEMPLATE_SUPPORT 0x00000001
  438. // The CA supports NT authentication for requests
  439. #define CA_FLAG_SUPPORTS_NT_AUTHENTICATION 0x00000002
  440. // The cert requests may be pended
  441. #define CA_FLAG_CA_SUPPORTS_MANUAL_AUTHENTICATION 0x00000004
  442. // The cert requests may be pended
  443. #define CA_FLAG_CA_SERVERTYPE_ADVANCED 0x00000008
  444. #define CA_MASK_SETTABLE_FLAGS 0x0000ffff
  445. //
  446. // CASetCAFlags
  447. // Sets the Flags of a cert type
  448. //
  449. // hCertType - handle to the CertType
  450. //
  451. // dwFlags - Flags to be set
  452. //
  453. CERTCLIAPI
  454. HRESULT
  455. WINAPI
  456. CASetCAFlags(
  457. IN HCAINFO hCAInfo,
  458. IN DWORD dwFlags
  459. );
  460. CERTCLIAPI
  461. HRESULT
  462. WINAPI
  463. CAGetCACertificate(
  464. IN HCAINFO hCAInfo,
  465. OUT PCCERT_CONTEXT *ppCert
  466. );
  467. //
  468. // CASetCACertificate - Set the certificate for a CA this CA.
  469. //
  470. // hCAInfo - Handle to an open CA object.
  471. //
  472. // pCert - Pointer to a certificate to set as the CA's certificate.
  473. //
  474. CERTCLIAPI
  475. HRESULT
  476. WINAPI
  477. CASetCACertificate(
  478. IN HCAINFO hCAInfo,
  479. IN PCCERT_CONTEXT pCert
  480. );
  481. //
  482. // CAGetCAExpiration
  483. // Get the expirations period for a CA.
  484. //
  485. // hCAInfo - Handle to an open CA handle.
  486. //
  487. // pdwExpiration - expiration period in dwUnits time
  488. //
  489. // pdwUnits - Units identifier
  490. //
  491. CERTCLIAPI
  492. HRESULT
  493. WINAPI
  494. CAGetCAExpiration(
  495. HCAINFO hCAInfo,
  496. DWORD * pdwExpiration,
  497. DWORD * pdwUnits
  498. );
  499. #define CA_UNITS_DAYS 1
  500. #define CA_UNITS_WEEKS 2
  501. #define CA_UNITS_MONTHS 3
  502. #define CA_UNITS_YEARS 4
  503. //
  504. // CASetCAExpiration
  505. // Set the expirations period for a CA.
  506. //
  507. // hCAInfo - Handle to an open CA handle.
  508. //
  509. // dwExpiration - expiration period in dwUnits time
  510. //
  511. // dwUnits - Units identifier
  512. //
  513. CERTCLIAPI
  514. HRESULT
  515. WINAPI
  516. CASetCAExpiration(
  517. HCAINFO hCAInfo,
  518. DWORD dwExpiration,
  519. DWORD dwUnits
  520. );
  521. //
  522. // CASetCASecurity
  523. // Set the list of Users, Groups, and Machines allowed to access this CA.
  524. //
  525. // hCAInfo - Handle to an open CA handle.
  526. //
  527. // pSD - Security descriptor for this CA
  528. //
  529. CERTCLIAPI
  530. HRESULT
  531. WINAPI
  532. CASetCASecurity(
  533. IN HCAINFO hCAInfo,
  534. IN PSECURITY_DESCRIPTOR pSD
  535. );
  536. //
  537. // CAGetCASecurity
  538. // Get the list of Users, Groups, and Machines allowed to access this CA.
  539. //
  540. // hCAInfo - Handle to an open CA handle.
  541. //
  542. // ppSD - Pointer to a location receiving the pointer to the security
  543. // descriptor. Free via LocalFree.
  544. //
  545. CERTCLIAPI
  546. HRESULT
  547. WINAPI
  548. CAGetCASecurity(
  549. IN HCAINFO hCAInfo,
  550. OUT PSECURITY_DESCRIPTOR * ppSD
  551. );
  552. //
  553. // CAAccessCheck
  554. // Determine whether the principal specified by
  555. // ClientToken can get a cert from the CA.
  556. //
  557. // hCAInfo - Handle to the CA
  558. //
  559. // ClientToken - Handle to an impersonation token that represents the client
  560. // attempting request this cert type. The handle must have
  561. // TOKEN_QUERY access to the token; otherwise, the function
  562. // fails with ERROR_ACCESS_DENIED.
  563. //
  564. // Return: S_OK on success
  565. //
  566. CERTCLIAPI
  567. HRESULT
  568. WINAPI
  569. CAAccessCheck(
  570. IN HCAINFO hCAInfo,
  571. IN HANDLE ClientToken
  572. );
  573. //
  574. // CAAccessCheckEx
  575. // Determine whether the principal specified by
  576. // ClientToken can get a cert from the CA.
  577. //
  578. // hCAInfo - Handle to the CA
  579. //
  580. // ClientToken - Handle to an impersonation token that represents the client
  581. // attempting request this cert type. The handle must have
  582. // TOKEN_QUERY access to the token; otherwise, the function
  583. // fails with ERROR_ACCESS_DENIED.
  584. //
  585. // dwOption - Can be one of the following:
  586. // CERTTYPE_ACCESS_CHECK_ENROLL
  587. // dwOption can be CERTTYPE_ACCESS_CHECK_NO_MAPPING to
  588. // disallow default mapping of client token
  589. //
  590. // Return: S_OK on success
  591. //
  592. CERTCLIAPI
  593. HRESULT
  594. WINAPI
  595. CAAccessCheckEx(
  596. IN HCAINFO hCAInfo,
  597. IN HANDLE ClientToken,
  598. IN DWORD dwOption
  599. );
  600. //
  601. // CAEnumCertTypesForCA - Given a HCAINFO, retrieve handle to the cert types
  602. // supported or known by this CA. CAEnumNextCertType can be used to enumerate
  603. // through the cert types.
  604. //
  605. // hCAInfo - Handle to an open CA handle or NULL if CT_FLAG_ENUM_ALL_TYPES
  606. // is set in dwFlags.
  607. //
  608. // dwFlags - The following flags may be or'd together
  609. // CA_FLAG_ENUM_ALL_TYPES
  610. // CT_FIND_LOCAL_SYSTEM
  611. // CT_ENUM_MACHINE_TYPES
  612. // CT_ENUM_USER_TYPES
  613. // CT_FLAG_NO_CACHE_LOOKUP
  614. //
  615. // phCertType - Enumeration of certificate types.
  616. //
  617. CERTCLIAPI
  618. HRESULT
  619. WINAPI
  620. CAEnumCertTypesForCA(
  621. IN HCAINFO hCAInfo,
  622. IN DWORD dwFlags,
  623. OUT HCERTTYPE * phCertType
  624. );
  625. //
  626. // CAEnumCertTypesForCAEx - Given a HCAINFO, retrieve handle to the cert types
  627. // supported or known by this CA. CAEnumNextCertTypeEx can be used to enumerate
  628. // through the cert types. It optional takes a LDAP handle.
  629. //
  630. // hCAInfo - Handle to an open CA handle or NULL if CT_FLAG_ENUM_ALL_TYPES
  631. // is set in dwFlags.
  632. //
  633. // wszScope - NULL if use the current domain.
  634. // If CT_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  635. // binding handle to use during finds.
  636. //
  637. // dwFlags - The following flags may be or'd together
  638. // CA_FLAG_ENUM_ALL_TYPES
  639. // CT_FIND_LOCAL_SYSTEM
  640. // CT_ENUM_MACHINE_TYPES
  641. // CT_ENUM_USER_TYPES
  642. // CT_FLAG_NO_CACHE_LOOKUP
  643. // CT_FLAG_SCOPE_IS_LDAP_HANDLE
  644. //
  645. // phCertType - Enumeration of certificate types.
  646. //
  647. CERTCLIAPI
  648. HRESULT
  649. WINAPI
  650. CAEnumCertTypesForCAEx(
  651. IN HCAINFO hCAInfo,
  652. IN LPCWSTR wszScope,
  653. IN DWORD dwFlags,
  654. OUT HCERTTYPE * phCertType
  655. );
  656. //
  657. // CAAddCACertificateType
  658. // Add a certificate type to a CA. If the cert type has already been added to
  659. // the CA, it will not be added again.
  660. //
  661. // hCAInfo - Handle to an open CA.
  662. //
  663. // hCertType - Cert type to add to CA.
  664. //
  665. CERTCLIAPI
  666. HRESULT
  667. WINAPI
  668. CAAddCACertificateType(
  669. HCAINFO hCAInfo,
  670. HCERTTYPE hCertType
  671. );
  672. //
  673. // CADeleteCACertificateType
  674. // Remove a certificate type from a CA. If the CA does not include this cert
  675. // type, this call does nothing.
  676. //
  677. // hCAInfo - Handle to an open CA.
  678. //
  679. // hCertType - Cert type to delete from CA.
  680. //
  681. CERTCLIAPI
  682. HRESULT
  683. WINAPI
  684. CARemoveCACertificateType(
  685. HCAINFO hCAInfo,
  686. HCERTTYPE hCertType
  687. );
  688. //*****************************************************************************
  689. //
  690. // Certificate Type APIs
  691. //
  692. //*****************************************************************************
  693. //
  694. // CAEnumCertTypes - Retrieve a handle to all known cert types
  695. // CAEnumNextCertType can be used to enumerate through the cert types.
  696. //
  697. // dwFlags - an oring of the following:
  698. // CT_FIND_LOCAL_SYSTEM
  699. // CT_ENUM_MACHINE_TYPES
  700. // CT_ENUM_USER_TYPES
  701. // CT_FLAG_NO_CACHE_LOOKUP
  702. //
  703. // phCertType - Enumeration of certificate types.
  704. //
  705. CERTCLIAPI
  706. HRESULT
  707. WINAPI
  708. CAEnumCertTypes(
  709. IN DWORD dwFlags,
  710. OUT HCERTTYPE * phCertType
  711. );
  712. //
  713. // CAEnumCertTypesEx - Retrieve a handle to all known cert types
  714. // CAEnumNextCertType can be used to enumerate through the cert types.
  715. //
  716. // wszScope - NULL if use the current domain.
  717. // If CT_FLAG_SCOPE_IS_LDAP_HANDLE is set, wszScope is the LDAP
  718. // binding handle to use during finds.
  719. //
  720. // dwFlags - an oring of the following:
  721. // CT_FIND_LOCAL_SYSTEM
  722. // CT_ENUM_MACHINE_TYPES
  723. // CT_ENUM_USER_TYPES
  724. // CT_FLAG_NO_CACHE_LOOKUP
  725. // CT_FLAG_SCOPE_IS_LDAP_HANDLE
  726. //
  727. // phCertType - Enumeration of certificate types.
  728. //
  729. CERTCLIAPI
  730. HRESULT
  731. WINAPI
  732. CAEnumCertTypesEx(
  733. IN LPCWSTR wszScope,
  734. IN DWORD dwFlags,
  735. OUT HCERTTYPE * phCertType
  736. );
  737. //
  738. // CAFindCertTypeByName
  739. // Find a cert type given a Name.
  740. //
  741. // wszCertType - Name of the cert type if CT_FIND_BY_OID is not set in dwFlags
  742. // The OID of the cert type if CT_FIND_BY_OID is set in dwFlags
  743. //
  744. // hCAInfo - NULL unless CT_FLAG_SCOPE_IS_LDAP_HANDLE is set in dwFlags
  745. //
  746. // dwFlags - an oring of the following
  747. // CT_FIND_LOCAL_SYSTEM
  748. // CT_ENUM_MACHINE_TYPES
  749. // CT_ENUM_USER_TYPES
  750. // CT_FLAG_NO_CACHE_LOOKUP
  751. // CT_FIND_BY_OID
  752. // CT_FLAG_SCOPE_IS_LDAP_HANDLE -- If this flag is set, hCAInfo
  753. // is the LDAP handle to use
  754. // during finds.
  755. // phCertType - Pointer to a cert type in which result is returned.
  756. //
  757. CERTCLIAPI
  758. HRESULT
  759. WINAPI
  760. CAFindCertTypeByName(
  761. IN LPCWSTR wszCertType,
  762. IN HCAINFO hCAInfo,
  763. IN DWORD dwFlags,
  764. OUT HCERTTYPE * phCertType
  765. );
  766. //*****************************************************************************
  767. //
  768. // Default cert type names
  769. //
  770. //*****************************************************************************
  771. #define wszCERTTYPE_USER L"User"
  772. #define wszCERTTYPE_USER_SIGNATURE L"UserSignature"
  773. #define wszCERTTYPE_SMARTCARD_USER L"SmartcardUser"
  774. #define wszCERTTYPE_USER_AS L"ClientAuth"
  775. #define wszCERTTYPE_USER_SMARTCARD_LOGON L"SmartcardLogon"
  776. #define wszCERTTYPE_EFS L"EFS"
  777. #define wszCERTTYPE_ADMIN L"Administrator"
  778. #define wszCERTTYPE_EFS_RECOVERY L"EFSRecovery"
  779. #define wszCERTTYPE_CODE_SIGNING L"CodeSigning"
  780. #define wszCERTTYPE_CTL_SIGNING L"CTLSigning"
  781. #define wszCERTTYPE_ENROLLMENT_AGENT L"EnrollmentAgent"
  782. #define wszCERTTYPE_MACHINE L"Machine"
  783. #define wszCERTTYPE_DC L"DomainController"
  784. #define wszCERTTYPE_WEBSERVER L"WebServer"
  785. #define wszCERTTYPE_KDC L"KDC"
  786. #define wszCERTTYPE_CA L"CA"
  787. #define wszCERTTYPE_SUBORDINATE_CA L"SubCA"
  788. #define wszCERTTYPE_CROSS_CA L"CrossCA"
  789. #define wszCERTTYPE_KEY_RECOVERY_AGENT L"KeyRecoveryAgent"
  790. #define wszCERTTYPE_CA_EXCHANGE L"CAExchange"
  791. #define wszCERTTYPE_DC_AUTH L"DomainControllerAuthentication"
  792. #define wszCERTTYPE_DS_EMAIL_REPLICATION L"DirectoryEmailReplication"
  793. #define wszCERTTYPE_IPSEC_ENDENTITY_ONLINE L"IPSECEndEntityOnline"
  794. #define wszCERTTYPE_IPSEC_ENDENTITY_OFFLINE L"IPSECEndEntityOffline"
  795. #define wszCERTTYPE_IPSEC_INTERMEDIATE_ONLINE L"IPSECIntermediateOnline"
  796. #define wszCERTTYPE_IPSEC_INTERMEDIATE_OFFLINE L"IPSECIntermediateOffline"
  797. #define wszCERTTYPE_ROUTER_OFFLINE L"OfflineRouter"
  798. #define wszCERTTYPE_ENROLLMENT_AGENT_OFFLINE L"EnrollmentAgentOffline"
  799. #define wszCERTTYPE_EXCHANGE_USER L"ExchangeUser"
  800. #define wszCERTTYPE_EXCHANGE_USER_SIGNATURE L"ExchangeUserSignature"
  801. #define wszCERTTYPE_MACHINE_ENROLLMENT_AGENT L"MachineEnrollmentAgent"
  802. #define wszCERTTYPE_CEP_ENCRYPTION L"CEPEncryption"
  803. //
  804. // CAUpdateCertType
  805. // Write any changes made to the cert type back to the type store
  806. //
  807. CERTCLIAPI
  808. HRESULT
  809. WINAPI
  810. CAUpdateCertType(
  811. IN HCERTTYPE hCertType
  812. );
  813. //
  814. // CADeleteCertType
  815. // Delete a CertType
  816. //
  817. // hCertType - Cert type to delete.
  818. //
  819. // NOTE: If this is called for a default cert type, it will revert back to its
  820. // default attributes (if it has been modified)
  821. //
  822. CERTCLIAPI
  823. HRESULT
  824. WINAPI
  825. CADeleteCertType(
  826. IN HCERTTYPE hCertType
  827. );
  828. //
  829. // CACloneCertType
  830. //
  831. // Clone a certificate type. The returned certificate type is a clone of the
  832. // input certificate type, with the new cert type name and display name. By default,
  833. // if the input template is a template for machines, all
  834. // CT_FLAG_SUBJECT_REQUIRE_XXXX bits in the subject name flag are turned off.
  835. //
  836. // hCertType - Cert type to be cloned.
  837. // wszCertType - Name of the new cert type.
  838. // wszFriendlyName - Friendly name of the new cert type. Could be NULL.
  839. // pvldap - The LDAP handle (LDAP *) to the directory. Could be NULL.
  840. // dwFlags - Can be an ORing of the following flags:
  841. //
  842. // CT_CLONE_KEEP_AUTOENROLLMENT_SETTING
  843. // CT_CLONE_KEEP_SUBJECT_NAME_SETTING
  844. //
  845. CERTCLIAPI
  846. HRESULT
  847. WINAPI
  848. CACloneCertType(
  849. IN HCERTTYPE hCertType,
  850. IN LPCWSTR wszCertType,
  851. IN LPCWSTR wszFriendlyName,
  852. IN LPVOID pvldap,
  853. IN DWORD dwFlags,
  854. OUT HCERTTYPE * phCertType
  855. );
  856. #define CT_CLONE_KEEP_AUTOENROLLMENT_SETTING 0x01
  857. #define CT_CLONE_KEEP_SUBJECT_NAME_SETTING 0x02
  858. //
  859. // CACreateCertType
  860. // Create a new cert type
  861. //
  862. // wszCertType - Name of the cert type
  863. //
  864. // wszScope - reserved. Must set to NULL.
  865. //
  866. // dwFlags - reserved. Must set to NULL.
  867. //
  868. // phCertType - returned cert type
  869. //
  870. CERTCLIAPI
  871. HRESULT
  872. WINAPI
  873. CACreateCertType(
  874. IN LPCWSTR wszCertType,
  875. IN LPCWSTR wszScope,
  876. IN DWORD dwFlags,
  877. OUT HCERTTYPE * phCertType
  878. );
  879. //
  880. // CAEnumNextCertType
  881. // Find the Next Cert Type in an enumeration.
  882. //
  883. // hPrevCertType - Previous cert type in enumeration
  884. //
  885. // phCertType - Pointer to a handle into which result is placed.
  886. // NULL if there are no more cert types in enumeration.
  887. //
  888. CERTCLIAPI
  889. HRESULT
  890. WINAPI
  891. CAEnumNextCertType(
  892. IN HCERTTYPE hPrevCertType,
  893. OUT HCERTTYPE * phCertType
  894. );
  895. //
  896. // CACountCertTypes
  897. // return the number of cert types in this enumeration
  898. //
  899. CERTCLIAPI
  900. DWORD
  901. WINAPI
  902. CACountCertTypes(
  903. IN HCERTTYPE hCertType
  904. );
  905. //
  906. // CACloseCertType
  907. // Close an open CertType handle
  908. //
  909. CERTCLIAPI
  910. HRESULT
  911. WINAPI
  912. CACloseCertType(
  913. IN HCERTTYPE hCertType
  914. );
  915. //
  916. // CAGetCertTypeProperty
  917. // Retrieve a property from a certificate type. This function is obsolete.
  918. // Caller should use CAGetCertTypePropertyEx instead
  919. //
  920. // hCertType - Handle to an open CertType object.
  921. //
  922. // wszPropertyName - Name of the CertType property.
  923. //
  924. // pawszPropertyValue - A pointer into which an array of WCHAR strings is
  925. // written, containing the values of the property. The
  926. // last element of the array points to NULL. If the
  927. // property is single valued, then the array returned
  928. // contains 2 elements, the first pointing to the value,
  929. // the second pointing to NULL. This pointer must be
  930. // freed by CAFreeCertTypeProperty.
  931. //
  932. // Returns - S_OK on success.
  933. //
  934. CERTCLIAPI
  935. HRESULT
  936. WINAPI
  937. CAGetCertTypeProperty(
  938. IN HCERTTYPE hCertType,
  939. IN LPCWSTR wszPropertyName,
  940. OUT LPWSTR ** pawszPropertyValue);
  941. //
  942. // CAGetCertTypePropertyEx
  943. // Retrieve a property from a certificate type.
  944. //
  945. // hCertType - Handle to an open CertType object.
  946. //
  947. // wszPropertyName - Name of the CertType property
  948. //
  949. // pPropertyValue - Depending on the value of wszPropertyName,
  950. // pPropertyValue is either DWORD * or LPWSTR **.
  951. //
  952. // It is a DWORD * for:
  953. // CERTTYPE_PROP_REVISION
  954. // CERTTYPE_PROP_SCHEMA_VERSION
  955. // CERTTYPE_PROP_MINOR_REVISION
  956. // CERTTYPE_PROP_RA_SIGNATURE
  957. // CERTTYPE_PROP_MIN_KEY_SIZE
  958. //
  959. // It is a LPWSTR ** for:
  960. // CERTTYPE_PROP_CN
  961. // CERTTYPE_PROP_DN
  962. // CERTTYPE_PROP_FRIENDLY_NAME
  963. // CERTTYPE_PROP_EXTENDED_KEY_USAGE
  964. // CERTTYPE_PROP_CSP_LIST
  965. // CERTTYPE_PROP_CRITICAL_EXTENSIONS
  966. // CERTTYPE_PROP_OID
  967. // CERTTYPE_PROP_SUPERSEDE
  968. // CERTTYPE_PROP_RA_POLICY
  969. // CERTTYPE_PROP_POLICY
  970. // CERTTYPE_PROP_DESCRIPTION
  971. //
  972. // A pointer into which an array of WCHAR strings is
  973. // written, containing the values of the property. The
  974. // last element of the array points to NULL. If the
  975. // property is single valued, then the array returned
  976. // contains 2 elements, the first pointing to the value,
  977. // the second pointing to NULL. This pointer must be
  978. // freed by CAFreeCertTypeProperty.
  979. //
  980. // Returns - S_OK on success.
  981. //
  982. CERTCLIAPI
  983. HRESULT
  984. WINAPI
  985. CAGetCertTypePropertyEx(
  986. IN HCERTTYPE hCertType,
  987. IN LPCWSTR wszPropertyName,
  988. OUT LPVOID pPropertyValue);
  989. //*****************************************************************************
  990. //
  991. // Certificate Type properties
  992. //
  993. //*****************************************************************************
  994. //*****************************************************************************
  995. //
  996. // The schema version one properties
  997. //
  998. //*****************************************************************************
  999. // Common name of the certificate type
  1000. #define CERTTYPE_PROP_CN L"cn"
  1001. // The common name of the certificate type. Same as CERTTYPE_PROP_CN
  1002. // This property is not settable.
  1003. #define CERTTYPE_PROP_DN L"distinguishedName"
  1004. // The display name of a cert type
  1005. #define CERTTYPE_PROP_FRIENDLY_NAME L"displayName"
  1006. // An array of extended key usage OIDs for a cert type
  1007. // NOTE: This property can also be set by setting
  1008. // the Extended Key Usage extension.
  1009. #define CERTTYPE_PROP_EXTENDED_KEY_USAGE L"pKIExtendedKeyUsage"
  1010. // The list of default CSPs for this cert type
  1011. #define CERTTYPE_PROP_CSP_LIST L"pKIDefaultCSPs"
  1012. // The list of critical extensions
  1013. #define CERTTYPE_PROP_CRITICAL_EXTENSIONS L"pKICriticalExtensions"
  1014. // The major version of the templates
  1015. #define CERTTYPE_PROP_REVISION L"revision"
  1016. // The description of the templates
  1017. #define CERTTYPE_PROP_DESCRIPTION L"templateDescription"
  1018. //*****************************************************************************
  1019. //
  1020. // The schema version two properties
  1021. //
  1022. //*****************************************************************************
  1023. // The schema version of the templates
  1024. // This property is not settable
  1025. #define CERTTYPE_PROP_SCHEMA_VERSION L"msPKI-Template-Schema-Version"
  1026. // The minor version of the templates
  1027. #define CERTTYPE_PROP_MINOR_REVISION L"msPKI-Template-Minor-Revision"
  1028. // The number of RA signatures required on a request referencing this template.
  1029. #define CERTTYPE_PROP_RA_SIGNATURE L"msPKI-RA-Signature"
  1030. // The minimal key size required
  1031. #define CERTTYPE_PROP_MIN_KEY_SIZE L"msPKI-Minimal-Key-Size"
  1032. // The OID of this template
  1033. #define CERTTYPE_PROP_OID L"msPKI-Cert-Template-OID"
  1034. // The OID of the template that this template supersedes
  1035. #define CERTTYPE_PROP_SUPERSEDE L"msPKI-Supersede-Templates"
  1036. // The RA issuer policy OIDs required in certs used to sign a request.
  1037. // Each signing cert's szOID_CERT_POLICIES extensions must contain at least one
  1038. // of the OIDs listed in the msPKI-RA-Policies property.
  1039. // Each OID listed must appear in the szOID_CERT_POLICIES extension of at least
  1040. // one signing cert.
  1041. #define CERTTYPE_PROP_RA_POLICY L"msPKI-RA-Policies"
  1042. // The RA application policy OIDs required in certs used to sign a request.
  1043. // Each signing cert's szOID_APPLICATION_CERT_POLICIES extensions must contain
  1044. // all of the OIDs listed in the msPKI-RA-Application-Policies property.
  1045. #define CERTTYPE_PROP_RA_APPLICATION_POLICY L"msPKI-RA-Application-Policies"
  1046. // The certificate issuer policy OIDs are placed in the szOID_CERT_POLICIES
  1047. // extension by the policy module.
  1048. #define CERTTYPE_PROP_POLICY L"msPKI-Certificate-Policy"
  1049. // The certificate application policy OIDs are placed in the
  1050. // szOID_APPLICATION_CERT_POLICIES extension by the policy module.
  1051. #define CERTTYPE_PROP_APPLICATION_POLICY L"msPKI-Certificate-Application-Policy"
  1052. #define CERTTYPE_SCHEMA_VERSION_1 1
  1053. #define CERTTYPE_SCHEMA_VERSION_2 (CERTTYPE_SCHEMA_VERSION_1 + 1)
  1054. //
  1055. // CASetCertTypeProperty
  1056. // Set a property of a CertType. This function is obsolete.
  1057. // Use CASetCertTypePropertyEx.
  1058. //
  1059. // hCertType - Handle to an open CertType object.
  1060. //
  1061. // wszPropertyName - Name of the CertType property
  1062. //
  1063. // awszPropertyValue - An array of values to set for this property. The
  1064. // last element of this array should be NULL. For
  1065. // single valued properties, the values beyond the first
  1066. // will be ignored upon update.
  1067. //
  1068. // Returns - S_OK on success.
  1069. //
  1070. CERTCLIAPI
  1071. HRESULT
  1072. WINAPI
  1073. CASetCertTypeProperty(
  1074. IN HCERTTYPE hCertType,
  1075. IN LPCWSTR wszPropertyName,
  1076. IN LPWSTR * awszPropertyValue
  1077. );
  1078. //
  1079. // CASetCertTypePropertyEx
  1080. // Set a property of a CertType
  1081. //
  1082. // hCertType - Handle to an open CertType object.
  1083. //
  1084. // wszPropertyName - Name of the CertType property
  1085. //
  1086. // pPropertyValue - Depending on the value of wszPropertyName,
  1087. // pPropertyValue is either DWORD * or LPWSTR *.
  1088. //
  1089. // It is a DWORD * for:
  1090. // CERTTYPE_PROP_REVISION
  1091. // CERTTYPE_PROP_MINOR_REVISION
  1092. // CERTTYPE_PROP_RA_SIGNATURE
  1093. // CERTTYPE_PROP_MIN_KEY_SIZE
  1094. //
  1095. // It is a LPWSTR * for:
  1096. // CERTTYPE_PROP_FRIENDLY_NAME
  1097. // CERTTYPE_PROP_EXTENDED_KEY_USAGE
  1098. // CERTTYPE_PROP_CSP_LIST
  1099. // CERTTYPE_PROP_CRITICAL_EXTENSIONS
  1100. // CERTTYPE_PROP_OID
  1101. // CERTTYPE_PROP_SUPERSEDE
  1102. // CERTTYPE_PROP_RA_POLICY
  1103. // CERTTYPE_PROP_POLICY
  1104. //
  1105. // - An array of values to set for this property. The
  1106. // last element of this array should be NULL. For
  1107. // single valued properties, the values beyond the first
  1108. // will be ignored upon update.
  1109. //
  1110. //
  1111. // - CertType of V1 schema can only set V1 properties.
  1112. //
  1113. // Returns - S_OK on success.
  1114. //
  1115. CERTCLIAPI
  1116. HRESULT
  1117. WINAPI
  1118. CASetCertTypePropertyEx(
  1119. IN HCERTTYPE hCertType,
  1120. IN LPCWSTR wszPropertyName,
  1121. IN LPVOID pPropertyValue
  1122. );
  1123. //
  1124. // CAFreeCertTypeProperty
  1125. // Frees a previously retrieved property value.
  1126. //
  1127. // hCertType - Handle to an open CertType object.
  1128. //
  1129. // awszPropertyValue - The values to be freed.
  1130. //
  1131. CERTCLIAPI
  1132. HRESULT
  1133. WINAPI
  1134. CAFreeCertTypeProperty(
  1135. IN HCERTTYPE hCertType,
  1136. IN LPWSTR * awszPropertyValue
  1137. );
  1138. //
  1139. // CAGetCertTypeExtensions
  1140. // Retrieves the extensions associated with this CertType.
  1141. //
  1142. // hCertType - Handle to an open CertType object.
  1143. // ppCertExtensions - Pointer to a PCERT_EXTENSIONS to receive the result
  1144. // of this call. Should be freed via a
  1145. // CAFreeCertTypeExtensions call.
  1146. //
  1147. CERTCLIAPI
  1148. HRESULT
  1149. WINAPI
  1150. CAGetCertTypeExtensions(
  1151. IN HCERTTYPE hCertType,
  1152. OUT PCERT_EXTENSIONS * ppCertExtensions
  1153. );
  1154. //
  1155. // CAGetCertTypeExtensionsEx
  1156. // Retrieves the extensions associated with this CertType.
  1157. //
  1158. // hCertType - Handle to an open CertType object.
  1159. // dwFlags - Indicate which extension to be returned.
  1160. // Can be an ORing of following flags:
  1161. //
  1162. // CT_EXTENSION_TEMPLATE
  1163. // CT_EXTENSION_KEY_USAGE
  1164. // CT_EXTENSION_EKU
  1165. // CT_EXTENSION_BASIC_CONTRAINTS
  1166. // CT_EXTENSION_APPLICATION_POLICY (Version 2 template only)
  1167. // CT_EXTENSION_ISSUANCE_POLICY (Version 2 template only)
  1168. //
  1169. // 0 means all avaiable extension for this CertType.
  1170. //
  1171. // pParam - Reserved. Must be NULL.
  1172. // ppCertExtensions - Pointer to a PCERT_EXTENSIONS to receive the result
  1173. // of this call. Should be freed via a
  1174. // CAFreeCertTypeExtensions call.
  1175. //
  1176. CERTCLIAPI
  1177. HRESULT
  1178. WINAPI
  1179. CAGetCertTypeExtensionsEx(
  1180. IN HCERTTYPE hCertType,
  1181. IN DWORD dwFlags,
  1182. IN LPVOID pParam,
  1183. OUT PCERT_EXTENSIONS * ppCertExtensions
  1184. );
  1185. #define CT_EXTENSION_TEMPLATE 0x01
  1186. #define CT_EXTENSION_KEY_USAGE 0x02
  1187. #define CT_EXTENSION_EKU 0x04
  1188. #define CT_EXTENSION_BASIC_CONTRAINTS 0x08
  1189. #define CT_EXTENSION_APPLICATION_POLICY 0x10
  1190. #define CT_EXTENSION_ISSUANCE_POLICY 0x20
  1191. //
  1192. // CAFreeCertTypeExtensions
  1193. // Free a PCERT_EXTENSIONS allocated by CAGetCertTypeExtensions
  1194. //
  1195. CERTCLIAPI
  1196. HRESULT
  1197. WINAPI
  1198. CAFreeCertTypeExtensions(
  1199. IN HCERTTYPE hCertType,
  1200. IN PCERT_EXTENSIONS pCertExtensions
  1201. );
  1202. //
  1203. // CASetCertTypeExtension
  1204. // Set the value of an extension for this
  1205. // cert type.
  1206. //
  1207. // hCertType - handle to the CertType
  1208. //
  1209. // wszExtensionId - OID for the extension
  1210. //
  1211. // dwFlags - Mark the extension critical
  1212. //
  1213. // pExtension - pointer to the appropriate extension structure
  1214. //
  1215. // Supported extensions/structures
  1216. //
  1217. // szOID_ENHANCED_KEY_USAGE CERT_ENHKEY_USAGE
  1218. // szOID_KEY_USAGE CRYPT_BIT_BLOB
  1219. // szOID_BASIC_CONSTRAINTS2 CERT_BASIC_CONSTRAINTS2_INFO
  1220. //
  1221. // Returns S_OK if successful.
  1222. //
  1223. CERTCLIAPI
  1224. HRESULT
  1225. WINAPI
  1226. CASetCertTypeExtension(
  1227. IN HCERTTYPE hCertType,
  1228. IN LPCWSTR wszExtensionId,
  1229. IN DWORD dwFlags,
  1230. IN LPVOID pExtension
  1231. );
  1232. #define CA_EXT_FLAG_CRITICAL 0x00000001
  1233. //
  1234. // CAGetCertTypeFlags
  1235. // Retrieve cert type flags.
  1236. // This function is obsolete. Use CAGetCertTypeFlagsEx.
  1237. //
  1238. // hCertType - handle to the CertType
  1239. //
  1240. // pdwFlags - pointer to DWORD receiving flags
  1241. //
  1242. CERTCLIAPI
  1243. HRESULT
  1244. WINAPI
  1245. CAGetCertTypeFlags(
  1246. IN HCERTTYPE hCertType,
  1247. OUT DWORD * pdwFlags
  1248. );
  1249. //
  1250. // CAGetCertTypeFlagsEx
  1251. // Retrieve cert type flags
  1252. //
  1253. // hCertType - handle to the CertType
  1254. //
  1255. // dwOption - Which flag to set
  1256. // Can be one of the following:
  1257. // CERTTYPE_ENROLLMENT_FLAG
  1258. // CERTTYPE_SUBJECT_NAME_FLAG
  1259. // CERTTYPE_PRIVATE_KEY_FLAG
  1260. // CERTTYPE_GENERAL_FLAG
  1261. //
  1262. // pdwFlags - pointer to DWORD receiving flags
  1263. //
  1264. CERTCLIAPI
  1265. HRESULT
  1266. WINAPI
  1267. CAGetCertTypeFlagsEx(
  1268. IN HCERTTYPE hCertType,
  1269. IN DWORD dwOption,
  1270. OUT DWORD * pdwFlags
  1271. );
  1272. //*****************************************************************************
  1273. //
  1274. // Cert Type Flags
  1275. //
  1276. // The CertType flags are grouped into 4 categories:
  1277. // 1. Enrollment Flags (CERTTYPE_ENROLLMENT_FLAG)
  1278. // 2. Certificate Subject Name Flags (CERTTYPE_SUBJECT_NAME_FLAG)
  1279. // 3. Private Key Flags (CERTTYPE_PRIVATE_KEY_FLAG)
  1280. // 4. General Flags (CERTTYPE_GENERAL_FLAG)
  1281. //*****************************************************************************
  1282. //Enrollment Flags
  1283. #define CERTTYPE_ENROLLMENT_FLAG 0x01
  1284. //Certificate Subject Name Flags
  1285. #define CERTTYPE_SUBJECT_NAME_FLAG 0x02
  1286. //Private Key Flags
  1287. #define CERTTYPE_PRIVATE_KEY_FLAG 0x03
  1288. //General Flags
  1289. #define CERTTYPE_GENERAL_FLAG 0x04
  1290. //*****************************************************************************
  1291. //
  1292. // Enrollment Flags:
  1293. //
  1294. //*****************************************************************************
  1295. // Include the symmetric algorithms in the requests
  1296. #define CT_FLAG_INCLUDE_SYMMETRIC_ALGORITHMS 0x00000001
  1297. // All certificate requests are pended
  1298. #define CT_FLAG_PEND_ALL_REQUESTS 0x00000002
  1299. // Publish the certificate to the KRA (key recovery agent container) on the DS
  1300. #define CT_FLAG_PUBLISH_TO_KRA_CONTAINER 0x00000004
  1301. // Publish the resultant cert to the userCertificate property in the DS
  1302. #define CT_FLAG_PUBLISH_TO_DS 0x00000008
  1303. // The autoenrollment will not enroll for new certificate if user has a certificate
  1304. // published on the DS with the same template name
  1305. #define CT_FLAG_AUTO_ENROLLMENT_CHECK_USER_DS_CERTIFICATE 0x00000010
  1306. // This cert is appropriate for auto-enrollment
  1307. #define CT_FLAG_AUTO_ENROLLMENT 0x00000020
  1308. // A previously issued certificate will valid subsequent enrollment requests
  1309. #define CT_FLAG_PREVIOUS_APPROVAL_VALIDATE_REENROLLMENT 0x00000040
  1310. // Domain authentication is not required.
  1311. #define CT_FLAG_DOMAIN_AUTHENTICATION_NOT_REQUIRED 0x00000080
  1312. // User interaction is required to enroll
  1313. #define CT_FLAG_USER_INTERACTION_REQUIRED 0x00000100
  1314. // Add szOID_CERTTYPE_EXTENSION (template name) extension
  1315. // This flag will ONLY be set on V1 certificate templates for W2K CA only.
  1316. #define CT_FLAG_ADD_TEMPLATE_NAME 0x00000200
  1317. // Remove invalid (expired or revoked) certificate from personal store
  1318. #define CT_FLAG_REMOVE_INVALID_CERTIFICATE_FROM_PERSONAL_STORE 0x00000400
  1319. //*****************************************************************************
  1320. //
  1321. // Certificate Subject Name Flags:
  1322. //
  1323. //*****************************************************************************
  1324. // The enrolling application must supply the subject name.
  1325. #define CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT 0x00000001
  1326. // The enrolling application must supply the subjectAltName in request
  1327. #define CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT_ALT_NAME 0x00010000
  1328. // Subject name should be full DN
  1329. #define CT_FLAG_SUBJECT_REQUIRE_DIRECTORY_PATH 0x80000000
  1330. // Subject name should be the common name
  1331. #define CT_FLAG_SUBJECT_REQUIRE_COMMON_NAME 0x40000000
  1332. // Subject name includes the e-mail name
  1333. #define CT_FLAG_SUBJECT_REQUIRE_EMAIL 0x20000000
  1334. // Subject name includes the DNS name as the common name
  1335. #define CT_FLAG_SUBJECT_REQUIRE_DNS_AS_CN 0x10000000
  1336. // Subject alt name includes DNS name
  1337. #define CT_FLAG_SUBJECT_ALT_REQUIRE_DNS 0x08000000
  1338. // Subject alt name includes email name
  1339. #define CT_FLAG_SUBJECT_ALT_REQUIRE_EMAIL 0x04000000
  1340. // Subject alt name requires UPN
  1341. #define CT_FLAG_SUBJECT_ALT_REQUIRE_UPN 0x02000000
  1342. // Subject alt name requires directory GUID
  1343. #define CT_FLAG_SUBJECT_ALT_REQUIRE_DIRECTORY_GUID 0x01000000
  1344. // Subject alt name requires SPN
  1345. #define CT_FLAG_SUBJECT_ALT_REQUIRE_SPN 0x00800000
  1346. //
  1347. // Obsolete name
  1348. // The following flags are obsolete. They are used by V1 templates in the
  1349. // general flags
  1350. //
  1351. #define CT_FLAG_IS_SUBJECT_REQ CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT
  1352. // The e-mail name of the principal will be added to the cert
  1353. #define CT_FLAG_ADD_EMAIL 0x00000002
  1354. // Add the object GUID for this principal
  1355. #define CT_FLAG_ADD_OBJ_GUID 0x00000004
  1356. // Add DS Name (full DN) to szOID_SUBJECT_ALT_NAME2 (Subj Alt Name 2) extension
  1357. // This flag is not SET in any of the V1 templates and is of no interests to
  1358. // V2 templates since it is not present on the UI and will never be set.
  1359. #define CT_FLAG_ADD_DIRECTORY_PATH 0x00000100
  1360. //*****************************************************************************
  1361. //
  1362. // Private Key Flags:
  1363. //
  1364. //*****************************************************************************
  1365. // Archival of the private key is allowed
  1366. #define CT_FLAG_ALLOW_PRIVATE_KEY_ARCHIVAL 0x00000001
  1367. #define CT_FLAG_REQUIRE_PRIVATE_KEY_ARCHIVAL CT_FLAG_ALLOW_PRIVATE_KEY_ARCHIVAL
  1368. // Make the key for this cert exportable.
  1369. #define CT_FLAG_EXPORTABLE_KEY 0x00000010
  1370. // Require the strong key protection UI when a new key is generated
  1371. #define CT_FLAG_STRONG_KEY_PROTECTION_REQUIRED 0x00000020
  1372. //*****************************************************************************
  1373. //
  1374. // General Flags
  1375. //
  1376. // More flags should start from 0x00000400
  1377. //
  1378. //*****************************************************************************
  1379. // This is a machine cert type
  1380. #define CT_FLAG_MACHINE_TYPE 0x00000040
  1381. // This is a CA cert type
  1382. #define CT_FLAG_IS_CA 0x00000080
  1383. // This is a cross CA cert type
  1384. #define CT_FLAG_IS_CROSS_CA 0x00000800
  1385. // The type is a default cert type (cannot be set). This flag will be set on
  1386. // all V1 templates. The templates can not be edited or deleted.
  1387. #define CT_FLAG_IS_DEFAULT 0x00010000
  1388. // The type has been modified, if it is default (cannot be set)
  1389. #define CT_FLAG_IS_MODIFIED 0x00020000
  1390. // settable flags for general flags
  1391. #define CT_MASK_SETTABLE_FLAGS 0x0000ffff
  1392. //
  1393. // CASetCertTypeFlags
  1394. // Sets the General Flags of a cert type.
  1395. // This function is obsolete. Use CASetCertTypeFlagsEx.
  1396. //
  1397. // hCertType - handle to the CertType
  1398. //
  1399. // dwFlags - Flags to be set
  1400. //
  1401. CERTCLIAPI
  1402. HRESULT
  1403. WINAPI
  1404. CASetCertTypeFlags(
  1405. IN HCERTTYPE hCertType,
  1406. IN DWORD dwFlags
  1407. );
  1408. //
  1409. // CASetCertTypeFlagsEx
  1410. // Sets the Flags of a cert type
  1411. //
  1412. // hCertType - handle to the CertType
  1413. //
  1414. // dwOption - Which flag to set
  1415. // Can be one of the following:
  1416. // CERTTYPE_ENROLLMENT_FLAG
  1417. // CERTTYPE_SUBJECT_NAME_FLAG
  1418. // CERTTYPE_PRIVATE_KEY_FLAG
  1419. // CERTTYPE_GENERAL_FLAG
  1420. //
  1421. // dwFlags - Value to be set
  1422. //
  1423. CERTCLIAPI
  1424. HRESULT
  1425. WINAPI
  1426. CASetCertTypeFlagsEx(
  1427. IN HCERTTYPE hCertType,
  1428. IN DWORD dwOption,
  1429. IN DWORD dwFlags
  1430. );
  1431. //
  1432. // CAGetCertTypeKeySpec
  1433. // Retrieve the CAPI Key Spec for this cert type
  1434. //
  1435. // hCertType - handle to the CertType
  1436. //
  1437. // pdwKeySpec - pointer to DWORD receiving key spec
  1438. //
  1439. CERTCLIAPI
  1440. HRESULT
  1441. WINAPI
  1442. CAGetCertTypeKeySpec(
  1443. IN HCERTTYPE hCertType,
  1444. OUT DWORD * pdwKeySpec
  1445. );
  1446. //
  1447. // CACertTypeSetKeySpec
  1448. // Sets the CAPI1 Key Spec of a cert type
  1449. //
  1450. // hCertType - handle to the CertType
  1451. //
  1452. // dwKeySpec - KeySpec to be set
  1453. //
  1454. CERTCLIAPI
  1455. HRESULT
  1456. WINAPI
  1457. CASetCertTypeKeySpec(
  1458. IN HCERTTYPE hCertType,
  1459. IN DWORD dwKeySpec
  1460. );
  1461. //
  1462. // CAGetCertTypeExpiration
  1463. // Retrieve the Expiration Info for this cert type
  1464. //
  1465. // pftExpiration - pointer to the FILETIME structure receiving
  1466. // the expiration period for this cert type.
  1467. //
  1468. // pftOverlap - pointer to the FILETIME structure receiving the
  1469. // suggested renewal overlap period for this cert type.
  1470. //
  1471. CERTCLIAPI
  1472. HRESULT
  1473. WINAPI
  1474. CAGetCertTypeExpiration(
  1475. IN HCERTTYPE hCertType,
  1476. OUT OPTIONAL FILETIME * pftExpiration,
  1477. OUT OPTIONAL FILETIME * pftOverlap
  1478. );
  1479. //
  1480. // CASetCertTypeExpiration
  1481. // Set the Expiration Info for this cert type
  1482. //
  1483. // pftExpiration - pointer to the FILETIME structure containing
  1484. // the expiration period for this cert type.
  1485. //
  1486. // pftOverlap - pointer to the FILETIME structure containing the
  1487. // suggested renewal overlap period for this cert type.
  1488. //
  1489. CERTCLIAPI
  1490. HRESULT
  1491. WINAPI
  1492. CASetCertTypeExpiration(
  1493. IN HCERTTYPE hCertType,
  1494. IN OPTIONAL FILETIME * pftExpiration,
  1495. IN OPTIONAL FILETIME * pftOverlap
  1496. );
  1497. //
  1498. // CACertTypeSetSecurity
  1499. // Set the list of Users, Groups, and Machines allowed
  1500. // to access this cert type.
  1501. //
  1502. // hCertType - handle to the CertType
  1503. //
  1504. // pSD - Security descriptor for this cert type
  1505. //
  1506. CERTCLIAPI
  1507. HRESULT
  1508. WINAPI
  1509. CACertTypeSetSecurity(
  1510. IN HCERTTYPE hCertType,
  1511. IN PSECURITY_DESCRIPTOR pSD
  1512. );
  1513. //
  1514. // CACertTypeGetSecurity
  1515. // Get the list of Users, Groups, and Machines allowed
  1516. // to access this cert type.
  1517. //
  1518. // hCertType - handle to the CertType
  1519. //
  1520. // ppaSidList - Pointer to a location receiving the pointer to the
  1521. // security descriptor. Free via LocalFree.
  1522. //
  1523. CERTCLIAPI
  1524. HRESULT
  1525. WINAPI
  1526. CACertTypeGetSecurity(
  1527. IN HCERTTYPE hCertType,
  1528. OUT PSECURITY_DESCRIPTOR * ppSD
  1529. );
  1530. //
  1531. //
  1532. // CACertTypeAccessCheck
  1533. // Determine whether the principal specified by
  1534. // ClientToken can be issued this cert type.
  1535. //
  1536. // hCertType - handle to the CertType
  1537. //
  1538. // ClientToken - Handle to an impersonation token that represents the
  1539. // client attempting to request this cert type. The
  1540. // handle must have TOKEN_QUERY access to the token;
  1541. // otherwise, the call fails with ERROR_ACCESS_DENIED.
  1542. //
  1543. // Return: S_OK on success
  1544. //
  1545. CERTCLIAPI
  1546. HRESULT
  1547. WINAPI
  1548. CACertTypeAccessCheck(
  1549. IN HCERTTYPE hCertType,
  1550. IN HANDLE ClientToken
  1551. );
  1552. //
  1553. //
  1554. // CACertTypeAccessCheckEx
  1555. // Determine whether the principal specified by
  1556. // ClientToken can be issued this cert type.
  1557. //
  1558. // hCertType - handle to the CertType
  1559. //
  1560. // ClientToken - Handle to an impersonation token that represents the
  1561. // client attempting to request this cert type. The
  1562. // handle must have TOKEN_QUERY access to the token;
  1563. // otherwise, the call fails with ERROR_ACCESS_DENIED.
  1564. //
  1565. // dwOption - Can be one of the following:
  1566. // CERTTYPE_ACCESS_CHECK_ENROLL
  1567. // CERTTYPE_ACCESS_CHECK_AUTO_ENROLL
  1568. //
  1569. // dwOption can be ORed with CERTTYPE_ACCESS_CHECK_NO_MAPPING
  1570. // to disallow default mapping of client token
  1571. //
  1572. // Return: S_OK on success
  1573. //
  1574. CERTCLIAPI
  1575. HRESULT
  1576. WINAPI
  1577. CACertTypeAccessCheckEx(
  1578. IN HCERTTYPE hCertType,
  1579. IN HANDLE ClientToken,
  1580. IN DWORD dwOption
  1581. );
  1582. #define CERTTYPE_ACCESS_CHECK_ENROLL 0x01
  1583. #define CERTTYPE_ACCESS_CHECK_AUTO_ENROLL 0x02
  1584. #define CERTTYPE_ACCESS_CHECK_NO_MAPPING 0x00010000
  1585. //
  1586. //
  1587. // CAInstallDefaultCertType
  1588. //
  1589. // Install default certificate types on the enterprise.
  1590. //
  1591. // dwFlags - Reserved. Must be 0 for now
  1592. //
  1593. //
  1594. // Return: S_OK on success
  1595. //
  1596. CERTCLIAPI
  1597. HRESULT
  1598. WINAPI
  1599. CAInstallDefaultCertType(
  1600. IN DWORD dwFlags
  1601. );
  1602. //
  1603. //
  1604. // CAIsCertTypeCurrent
  1605. //
  1606. // Check if the certificate type on the DS is up to date
  1607. //
  1608. // dwFlags - Reserved. Must be 0 for now
  1609. // wszCertType - The name for the certificate type
  1610. //
  1611. // Return: TRUE if the cert type is update to date
  1612. //
  1613. CERTCLIAPI
  1614. BOOL
  1615. WINAPI
  1616. CAIsCertTypeCurrent(
  1617. IN DWORD dwFlags,
  1618. IN LPWSTR wszCertType
  1619. );
  1620. //*****************************************************************************
  1621. //
  1622. // OID management APIs
  1623. //
  1624. //*****************************************************************************
  1625. //
  1626. // CAOIDCreateNew
  1627. // Create a new OID based on the enterprise base
  1628. //
  1629. // dwType - Can be one of the following:
  1630. // CERT_OID_TYPE_TEMPLATE
  1631. // CERT_OID_TYPE_ISSUER_POLICY
  1632. // CERT_OID_TYPE_APPLICATION_POLICY
  1633. //
  1634. // dwFlag - Reserved. Must be 0.
  1635. //
  1636. // ppwszOID - Return the new OID. Free memory via LocalFree().
  1637. //
  1638. // Returns S_OK if successful.
  1639. //
  1640. CERTCLIAPI
  1641. HRESULT
  1642. WINAPI
  1643. CAOIDCreateNew(
  1644. IN DWORD dwType,
  1645. IN DWORD dwFlag,
  1646. OUT LPWSTR *ppwszOID);
  1647. #define CERT_OID_TYPE_TEMPLATE 0x01
  1648. #define CERT_OID_TYPE_ISSUER_POLICY 0x02
  1649. #define CERT_OID_TYPE_APPLICATION_POLICY 0x03
  1650. //
  1651. // CAOIDAdd
  1652. // Add an OID to the DS repository
  1653. //
  1654. // dwType - Can be one of the following:
  1655. // CERT_OID_TYPE_TEMPLATE
  1656. // CERT_OID_TYPE_ISSUER_POLICY
  1657. // CERT_OID_TYPE_APPLICATION_POLICY
  1658. //
  1659. // dwFlag - Reserved. Must be 0.
  1660. //
  1661. // pwszOID - The OID to add.
  1662. //
  1663. // Returns S_OK if successful.
  1664. // Returns CRYPT_E_EXISTS if the OID alreay exits in the DS repository
  1665. //
  1666. CERTCLIAPI
  1667. HRESULT
  1668. WINAPI
  1669. CAOIDAdd(
  1670. IN DWORD dwType,
  1671. IN DWORD dwFlag,
  1672. IN LPCWSTR pwszOID);
  1673. //
  1674. // CAOIDDelete
  1675. // Delete the OID from the DS repository
  1676. //
  1677. // pwszOID - The OID to delete.
  1678. //
  1679. // Returns S_OK if successful.
  1680. //
  1681. CERTCLIAPI
  1682. HRESULT
  1683. WINAPI
  1684. CAOIDDelete(
  1685. IN LPCWSTR pwszOID);
  1686. //
  1687. // CAOIDSetProperty
  1688. // Set a property on an OID.
  1689. //
  1690. // pwszOID - The OID whose value is set
  1691. // dwProperty - The property name. Can be one of the following:
  1692. // CERT_OID_PROPERTY_DISPLAY_NAME
  1693. // CERT_OID_PROPERTY_CPS
  1694. //
  1695. // pPropValue - The value of the property.
  1696. // If dwProperty is CERT_OID_PROPERTY_DISPLAY_NAME,
  1697. // pPropValue is LPWSTR.
  1698. // if dwProperty is CERT_OID_PROPERTY_CPS,
  1699. // pPropValue is LPWSTR.
  1700. // NULL will remove the property
  1701. //
  1702. //
  1703. // Returns S_OK if successful.
  1704. //
  1705. CERTCLIAPI
  1706. HRESULT
  1707. WINAPI
  1708. CAOIDSetProperty(
  1709. IN LPCWSTR pwszOID,
  1710. IN DWORD dwProperty,
  1711. IN LPVOID pPropValue);
  1712. #define CERT_OID_PROPERTY_DISPLAY_NAME 0x01
  1713. #define CERT_OID_PROPERTY_CPS 0x02
  1714. #define CERT_OID_PROPERTY_TYPE 0x03
  1715. //
  1716. // CAOIDGetProperty
  1717. // Get a property on an OID.
  1718. //
  1719. // pwszOID - The OID whose value is queried
  1720. // dwProperty - The property name. Can be one of the following:
  1721. // CERT_OID_PROPERTY_DISPLAY_NAME
  1722. // CERT_OID_PROPERTY_CPS
  1723. // CERT_OID_PROPERTY_TYPE
  1724. //
  1725. // pPropValue - The value of the property.
  1726. // If dwProperty is CERT_OID_PROPERTY_DISPLAY_NAME,
  1727. // pPropValue is LPWSTR *.
  1728. // if dwProperty is CERT_OID_PROPERTY_CPS, pPropValue is
  1729. // LPWSTR *.
  1730. //
  1731. // Free the above properties via CAOIDFreeProperty().
  1732. //
  1733. // If dwProperty is CERT_OID_PROPERTY_TYPE, pPropValue
  1734. // is DWORD *.
  1735. //
  1736. // Returns S_OK if successful.
  1737. //
  1738. CERTCLIAPI
  1739. HRESULT
  1740. WINAPI
  1741. CAOIDGetProperty(
  1742. IN LPCWSTR pwszOID,
  1743. IN DWORD dwProperty,
  1744. OUT LPVOID pPropValue);
  1745. //
  1746. // CAOIDFreeProperty
  1747. // Free a property returned from CAOIDGetProperty
  1748. //
  1749. // pPropValue - The value of the property.
  1750. //
  1751. // Returns S_OK if successful.
  1752. //
  1753. CERTCLIAPI
  1754. HRESULT
  1755. WINAPI
  1756. CAOIDFreeProperty(
  1757. IN LPVOID pPropValue);
  1758. //
  1759. // CAOIDGetLdapURL
  1760. //
  1761. // Return the LDAP URL for OID repository. In the format of
  1762. // LDAP:///DN of the Repository/all attributes?one?filter. The filter
  1763. // is determined by dwType.
  1764. //
  1765. // dwType - Can be one of the following:
  1766. // CERT_OID_TYPE_TEMPLATE
  1767. // CERT_OID_TYPE_ISSUER_POLICY
  1768. // CERT_OID_TYPE_APPLICATION_POLICY
  1769. // CERT_OID_TYPE_ALL
  1770. //
  1771. // dwFlag - Reserved. Must be 0.
  1772. //
  1773. // ppwszURL - Return the URL. Free memory via CAOIDFreeLdapURL.
  1774. //
  1775. // Returns S_OK if successful.
  1776. //
  1777. CERTCLIAPI
  1778. HRESULT
  1779. WINAPI
  1780. CAOIDGetLdapURL(
  1781. IN DWORD dwType,
  1782. IN DWORD dwFlag,
  1783. OUT LPWSTR *ppwszURL);
  1784. #define CERT_OID_TYPE_ALL 0x0
  1785. //
  1786. // CAOIDFreeLDAPURL
  1787. // Free the URL returned from CAOIDGetLdapURL
  1788. //
  1789. // pwszURL - The URL returned from CAOIDGetLdapURL
  1790. //
  1791. // Returns S_OK if successful.
  1792. //
  1793. CERTCLIAPI
  1794. HRESULT
  1795. WINAPI
  1796. CAOIDFreeLdapURL(
  1797. IN LPCWSTR pwszURL);
  1798. //the LDAP properties for OID class
  1799. #define OID_PROP_TYPE L"flags"
  1800. #define OID_PROP_OID L"msPKI-Cert-Template-OID"
  1801. #define OID_PROP_DISPLAY_NAME L"displayName"
  1802. #define OID_PROP_CPS L"msPKI-OID-CPS"
  1803. #define OID_PROP_LOCALIZED_NAME L"msPKI-OIDLocalizedName"
  1804. //*****************************************************************************
  1805. //
  1806. // Cert Type Change Query APIS
  1807. //
  1808. //*****************************************************************************
  1809. //
  1810. // CACertTypeRegisterQuery
  1811. //
  1812. // Regiser the calling thread to query if any modification has happened
  1813. // to cert type information on the directory
  1814. //
  1815. //
  1816. // dwFlag - Reserved. Must be 0.
  1817. //
  1818. // pvldap - The LDAP handle to the directory (LDAP *). Optional input.
  1819. // If pvldap is not NULL, then the caller has to call
  1820. // CACertTypeUnregisterQuery before unbind the pldap.
  1821. //
  1822. // pHCertTypeQuery - Receive the HCERTTYPEQUERY handle upon success.
  1823. //
  1824. // Returns S_OK if successful.
  1825. //
  1826. //
  1827. CERTCLIAPI
  1828. HRESULT
  1829. WINAPI
  1830. CACertTypeRegisterQuery(
  1831. IN DWORD dwFlag,
  1832. IN LPVOID pvldap,
  1833. OUT HCERTTYPEQUERY *phCertTypeQuery);
  1834. //
  1835. // CACertTypeQuery
  1836. //
  1837. // Returns a change sequence number which is incremented by 1 whenever
  1838. // cert type information on the directory is changed.
  1839. //
  1840. // hCertTypeQuery - The hCertTypeQuery returned from previous
  1841. // CACertTypeRegisterQuery calls.
  1842. //
  1843. // *pdwChangeSequence - Returns a DWORD, which is incremented by 1
  1844. // whenever any changes has happened to cert type
  1845. // information on the directory since the last
  1846. // call to CACertTypeRegisterQuery or CACertTypeQuery.
  1847. //
  1848. //
  1849. //
  1850. // Returns S_OK if successful.
  1851. //
  1852. //
  1853. CERTCLIAPI
  1854. HRESULT
  1855. WINAPI
  1856. CACertTypeQuery(
  1857. IN HCERTTYPEQUERY hCertTypeQuery,
  1858. OUT DWORD *pdwChangeSequence);
  1859. //
  1860. // CACertTypeUnregisterQuery
  1861. //
  1862. // Unregister the calling thread to query if any modification has happened
  1863. // to cert type information on the directory
  1864. //
  1865. //
  1866. // hCertTypeQuery - The hCertTypeQuery returned from previous
  1867. // CACertTypeRegisterQuery calls.
  1868. //
  1869. // Returns S_OK if successful.
  1870. //
  1871. //
  1872. CERTCLIAPI
  1873. HRESULT
  1874. WINAPI
  1875. CACertTypeUnregisterQuery(
  1876. IN HCERTTYPEQUERY hCertTypeQuery);
  1877. //*****************************************************************************
  1878. //
  1879. // Autoenrollment APIs
  1880. //
  1881. //*****************************************************************************
  1882. //
  1883. // CACreateLocalAutoEnrollmentObject
  1884. // Create an auto-enrollment object on the local machine.
  1885. //
  1886. // pwszCertType - The name of the certificate type for which to create the
  1887. // auto-enrollment object
  1888. //
  1889. // awszCAs - The list of CAs to add to the auto-enrollment object with the
  1890. // last entry in the list being NULL. If the list is NULL or
  1891. // empty, then it create an auto-enrollment object which
  1892. // instructs the system to enroll for a cert at any CA
  1893. // supporting the requested certificate type.
  1894. //
  1895. // pSignerInfo - not used, must be NULL.
  1896. //
  1897. // dwFlags - can be CERT_SYSTEM_STORE_CURRENT_USER or
  1898. // CERT_SYSTEM_STORE_LOCAL_MACHINE, indicating auto-enrollment
  1899. // store in which the auto-enrollment object is created.
  1900. //
  1901. // Return: S_OK on success.
  1902. //
  1903. CERTCLIAPI
  1904. HRESULT
  1905. WINAPI
  1906. CACreateLocalAutoEnrollmentObject(
  1907. IN LPCWSTR pwszCertType,
  1908. IN OPTIONAL WCHAR ** awszCAs,
  1909. IN OPTIONAL PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1910. IN DWORD dwFlags);
  1911. //
  1912. // CADeleteLocalAutoEnrollmentObject
  1913. // Delete an auto-enrollment object on the local machine.
  1914. //
  1915. // pwszCertType - The name of the certificate type for which to delete the
  1916. // auto-enrollment object
  1917. //
  1918. // awszCAs - not used. must be NULL. All callers to CACreateLocalAutoEnrollmentObject
  1919. // have supplied NULL.
  1920. //
  1921. // pSignerInfo - not used, must be NULL.
  1922. //
  1923. // dwFlags - can be CERT_SYSTEM_STORE_CURRENT_USER or
  1924. // CERT_SYSTEM_STORE_LOCAL_MACHINE, indicating auto-enrollment
  1925. // store in which the auto-enrollment object is deleted.
  1926. //
  1927. // Return: S_OK on success.
  1928. //
  1929. CERTCLIAPI
  1930. HRESULT
  1931. WINAPI
  1932. CADeleteLocalAutoEnrollmentObject(
  1933. IN LPCWSTR pwszCertType,
  1934. IN OPTIONAL WCHAR ** awszCAs,
  1935. IN OPTIONAL PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1936. IN DWORD dwFlags);
  1937. //
  1938. // CACreateAutoEnrollmentObjectEx
  1939. // Create an auto-enrollment object in the indicated store.
  1940. //
  1941. // pwszCertType - The name of the certificate type for which to create the
  1942. // auto-enrollment object
  1943. //
  1944. // pwszObjectID - An identifying string for this autoenrollment object. NULL
  1945. // may be passed if this object is simply to be identified by
  1946. // its certificate template. An autoenrollment object is
  1947. // identified by a combination of its object id and its cert
  1948. // type name.
  1949. //
  1950. // awszCAs - The list of CAs to add to the auto-enrollment object, with
  1951. // the last entry in the list being NULL. If the list is NULL
  1952. // or empty, then it create an auto-enrollment object which
  1953. // instructs the system to enroll for a cert at any CA
  1954. // supporting the requested certificate type.
  1955. //
  1956. // pSignerInfo - not used, must be NULL.
  1957. //
  1958. // StoreProvider - see CertOpenStore
  1959. //
  1960. // dwFlags - see CertOpenStore
  1961. //
  1962. // pvPara - see CertOpenStore
  1963. //
  1964. // Return: S_OK on success.
  1965. //
  1966. //
  1967. CERTCLIAPI
  1968. HRESULT
  1969. WINAPI
  1970. CACreateAutoEnrollmentObjectEx(
  1971. IN LPCWSTR pwszCertType,
  1972. IN LPCWSTR wszObjectID,
  1973. IN WCHAR ** awszCAs,
  1974. IN PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1975. IN LPCSTR StoreProvider,
  1976. IN DWORD dwFlags,
  1977. IN const void * pvPara);
  1978. typedef struct _CERTSERVERENROLL
  1979. {
  1980. DWORD Disposition;
  1981. HRESULT hrLastStatus;
  1982. DWORD RequestId;
  1983. BYTE *pbCert;
  1984. DWORD cbCert;
  1985. BYTE *pbCertChain;
  1986. DWORD cbCertChain;
  1987. WCHAR *pwszDispositionMessage;
  1988. } CERTSERVERENROLL;
  1989. //*****************************************************************************
  1990. //
  1991. // Cert Server RPC interfaces:
  1992. //
  1993. //*****************************************************************************
  1994. CERTCLIAPI
  1995. HRESULT
  1996. WINAPI
  1997. CertServerSubmitRequest(
  1998. IN DWORD Flags,
  1999. IN BYTE const *pbRequest,
  2000. IN DWORD cbRequest,
  2001. OPTIONAL IN WCHAR const *pwszRequestAttributes,
  2002. IN WCHAR const *pwszServerName,
  2003. IN WCHAR const *pwszAuthority,
  2004. OUT CERTSERVERENROLL **ppcsEnroll); // free via CertServerFreeMemory
  2005. CERTCLIAPI
  2006. HRESULT
  2007. WINAPI
  2008. CertServerRetrievePending(
  2009. IN DWORD RequestId,
  2010. OPTIONAL IN WCHAR const *pwszSerialNumber,
  2011. IN WCHAR const *pwszServerName,
  2012. IN WCHAR const *pwszAuthority,
  2013. OUT CERTSERVERENROLL **ppcsEnroll); // free via CertServerFreeMemory
  2014. CERTCLIAPI
  2015. VOID
  2016. WINAPI
  2017. CertServerFreeMemory(
  2018. IN VOID *pv);
  2019. enum ENUM_PERIOD
  2020. {
  2021. ENUM_PERIOD_INVALID = -1,
  2022. ENUM_PERIOD_SECONDS = 0,
  2023. ENUM_PERIOD_MINUTES,
  2024. ENUM_PERIOD_HOURS,
  2025. ENUM_PERIOD_DAYS,
  2026. ENUM_PERIOD_WEEKS,
  2027. ENUM_PERIOD_MONTHS,
  2028. ENUM_PERIOD_YEARS
  2029. };
  2030. typedef struct _PERIODUNITS
  2031. {
  2032. LONG lCount;
  2033. enum ENUM_PERIOD enumPeriod;
  2034. } PERIODUNITS;
  2035. HRESULT
  2036. caTranslateFileTimePeriodToPeriodUnits(
  2037. IN FILETIME const *pftGMT,
  2038. IN BOOL fExact,
  2039. OUT DWORD *pcPeriodUnits,
  2040. OUT PERIODUNITS **prgPeriodUnits);
  2041. #ifdef __cplusplus
  2042. }
  2043. #endif
  2044. #endif //__CERTCA_H__