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.

2393 lines
66 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_WORKSTATION L"Workstation"
  784. #define wszCERTTYPE_DC L"DomainController"
  785. #define wszCERTTYPE_RASIASSERVER L"RASAndIASServer"
  786. #define wszCERTTYPE_WEBSERVER L"WebServer"
  787. #define wszCERTTYPE_KDC L"KDC"
  788. #define wszCERTTYPE_CA L"CA"
  789. #define wszCERTTYPE_SUBORDINATE_CA L"SubCA"
  790. #define wszCERTTYPE_CROSS_CA L"CrossCA"
  791. #define wszCERTTYPE_KEY_RECOVERY_AGENT L"KeyRecoveryAgent"
  792. #define wszCERTTYPE_CA_EXCHANGE L"CAExchange"
  793. #define wszCERTTYPE_DC_AUTH L"DomainControllerAuthentication"
  794. #define wszCERTTYPE_DS_EMAIL_REPLICATION L"DirectoryEmailReplication"
  795. #define wszCERTTYPE_IPSEC_ENDENTITY_ONLINE L"IPSECEndEntityOnline"
  796. #define wszCERTTYPE_IPSEC_ENDENTITY_OFFLINE L"IPSECEndEntityOffline"
  797. #define wszCERTTYPE_IPSEC_INTERMEDIATE_ONLINE L"IPSECIntermediateOnline"
  798. #define wszCERTTYPE_IPSEC_INTERMEDIATE_OFFLINE L"IPSECIntermediateOffline"
  799. #define wszCERTTYPE_ROUTER_OFFLINE L"OfflineRouter"
  800. #define wszCERTTYPE_ENROLLMENT_AGENT_OFFLINE L"EnrollmentAgentOffline"
  801. #define wszCERTTYPE_EXCHANGE_USER L"ExchangeUser"
  802. #define wszCERTTYPE_EXCHANGE_USER_SIGNATURE L"ExchangeUserSignature"
  803. #define wszCERTTYPE_MACHINE_ENROLLMENT_AGENT L"MachineEnrollmentAgent"
  804. #define wszCERTTYPE_CEP_ENCRYPTION L"CEPEncryption"
  805. //
  806. // CAUpdateCertType
  807. // Write any changes made to the cert type back to the type store
  808. //
  809. CERTCLIAPI
  810. HRESULT
  811. WINAPI
  812. CAUpdateCertType(
  813. IN HCERTTYPE hCertType
  814. );
  815. //
  816. // CADeleteCertType
  817. // Delete a CertType
  818. //
  819. // hCertType - Cert type to delete.
  820. //
  821. // NOTE: If this is called for a default cert type, it will revert back to its
  822. // default attributes (if it has been modified)
  823. //
  824. CERTCLIAPI
  825. HRESULT
  826. WINAPI
  827. CADeleteCertType(
  828. IN HCERTTYPE hCertType
  829. );
  830. //
  831. // CACloneCertType
  832. //
  833. // Clone a certificate type. The returned certificate type is a clone of the
  834. // input certificate type, with the new cert type name and display name. By default,
  835. // if the input template is a template for machines, all
  836. // CT_FLAG_SUBJECT_REQUIRE_XXXX bits in the subject name flag are turned off.
  837. //
  838. // hCertType - Cert type to be cloned.
  839. // wszCertType - Name of the new cert type.
  840. // wszFriendlyName - Friendly name of the new cert type. Could be NULL.
  841. // pvldap - The LDAP handle (LDAP *) to the directory. Could be NULL.
  842. // dwFlags - Can be an ORing of the following flags:
  843. //
  844. // CT_CLONE_KEEP_AUTOENROLLMENT_SETTING
  845. // CT_CLONE_KEEP_SUBJECT_NAME_SETTING
  846. //
  847. CERTCLIAPI
  848. HRESULT
  849. WINAPI
  850. CACloneCertType(
  851. IN HCERTTYPE hCertType,
  852. IN LPCWSTR wszCertType,
  853. IN LPCWSTR wszFriendlyName,
  854. IN LPVOID pvldap,
  855. IN DWORD dwFlags,
  856. OUT HCERTTYPE * phCertType
  857. );
  858. #define CT_CLONE_KEEP_AUTOENROLLMENT_SETTING 0x01
  859. #define CT_CLONE_KEEP_SUBJECT_NAME_SETTING 0x02
  860. //
  861. // CACreateCertType
  862. // Create a new cert type
  863. //
  864. // wszCertType - Name of the cert type
  865. //
  866. // wszScope - reserved. Must set to NULL.
  867. //
  868. // dwFlags - reserved. Must set to NULL.
  869. //
  870. // phCertType - returned cert type
  871. //
  872. CERTCLIAPI
  873. HRESULT
  874. WINAPI
  875. CACreateCertType(
  876. IN LPCWSTR wszCertType,
  877. IN LPCWSTR wszScope,
  878. IN DWORD dwFlags,
  879. OUT HCERTTYPE * phCertType
  880. );
  881. //
  882. // CAEnumNextCertType
  883. // Find the Next Cert Type in an enumeration.
  884. //
  885. // hPrevCertType - Previous cert type in enumeration
  886. //
  887. // phCertType - Pointer to a handle into which result is placed.
  888. // NULL if there are no more cert types in enumeration.
  889. //
  890. CERTCLIAPI
  891. HRESULT
  892. WINAPI
  893. CAEnumNextCertType(
  894. IN HCERTTYPE hPrevCertType,
  895. OUT HCERTTYPE * phCertType
  896. );
  897. //
  898. // CACountCertTypes
  899. // return the number of cert types in this enumeration
  900. //
  901. CERTCLIAPI
  902. DWORD
  903. WINAPI
  904. CACountCertTypes(
  905. IN HCERTTYPE hCertType
  906. );
  907. //
  908. // CACloseCertType
  909. // Close an open CertType handle
  910. //
  911. CERTCLIAPI
  912. HRESULT
  913. WINAPI
  914. CACloseCertType(
  915. IN HCERTTYPE hCertType
  916. );
  917. //
  918. // CAGetCertTypeProperty
  919. // Retrieve a property from a certificate type. This function is obsolete.
  920. // Caller should use CAGetCertTypePropertyEx instead
  921. //
  922. // hCertType - Handle to an open CertType object.
  923. //
  924. // wszPropertyName - Name of the CertType property.
  925. //
  926. // pawszPropertyValue - A pointer into which an array of WCHAR strings is
  927. // written, containing the values of the property. The
  928. // last element of the array points to NULL. If the
  929. // property is single valued, then the array returned
  930. // contains 2 elements, the first pointing to the value,
  931. // the second pointing to NULL. This pointer must be
  932. // freed by CAFreeCertTypeProperty.
  933. //
  934. // Returns - S_OK on success.
  935. //
  936. CERTCLIAPI
  937. HRESULT
  938. WINAPI
  939. CAGetCertTypeProperty(
  940. IN HCERTTYPE hCertType,
  941. IN LPCWSTR wszPropertyName,
  942. OUT LPWSTR ** pawszPropertyValue);
  943. //
  944. // CAGetCertTypePropertyEx
  945. // Retrieve a property from a certificate type.
  946. //
  947. // hCertType - Handle to an open CertType object.
  948. //
  949. // wszPropertyName - Name of the CertType property
  950. //
  951. // pPropertyValue - Depending on the value of wszPropertyName,
  952. // pPropertyValue is either DWORD * or LPWSTR **.
  953. //
  954. // It is a DWORD * for:
  955. // CERTTYPE_PROP_REVISION
  956. // CERTTYPE_PROP_SCHEMA_VERSION
  957. // CERTTYPE_PROP_MINOR_REVISION
  958. // CERTTYPE_PROP_RA_SIGNATURE
  959. // CERTTYPE_PROP_MIN_KEY_SIZE
  960. //
  961. // It is a LPWSTR ** for:
  962. // CERTTYPE_PROP_CN
  963. // CERTTYPE_PROP_DN
  964. // CERTTYPE_PROP_FRIENDLY_NAME
  965. // CERTTYPE_PROP_EXTENDED_KEY_USAGE
  966. // CERTTYPE_PROP_CSP_LIST
  967. // CERTTYPE_PROP_CRITICAL_EXTENSIONS
  968. // CERTTYPE_PROP_OID
  969. // CERTTYPE_PROP_SUPERSEDE
  970. // CERTTYPE_PROP_RA_POLICY
  971. // CERTTYPE_PROP_POLICY
  972. // CERTTYPE_PROP_DESCRIPTION
  973. //
  974. // A pointer into which an array of WCHAR strings is
  975. // written, containing the values of the property. The
  976. // last element of the array points to NULL. If the
  977. // property is single valued, then the array returned
  978. // contains 2 elements, the first pointing to the value,
  979. // the second pointing to NULL. This pointer must be
  980. // freed by CAFreeCertTypeProperty.
  981. //
  982. // Returns - S_OK on success.
  983. //
  984. CERTCLIAPI
  985. HRESULT
  986. WINAPI
  987. CAGetCertTypePropertyEx(
  988. IN HCERTTYPE hCertType,
  989. IN LPCWSTR wszPropertyName,
  990. OUT LPVOID pPropertyValue);
  991. //*****************************************************************************
  992. //
  993. // Certificate Type properties
  994. //
  995. //*****************************************************************************
  996. //*****************************************************************************
  997. //
  998. // The schema version one properties
  999. //
  1000. //*****************************************************************************
  1001. // Common name of the certificate type
  1002. #define CERTTYPE_PROP_CN L"cn"
  1003. // The common name of the certificate type. Same as CERTTYPE_PROP_CN
  1004. // This property is not settable.
  1005. #define CERTTYPE_PROP_DN L"distinguishedName"
  1006. // The display name of a cert type
  1007. #define CERTTYPE_PROP_FRIENDLY_NAME L"displayName"
  1008. // An array of extended key usage OIDs for a cert type
  1009. // NOTE: This property can also be set by setting
  1010. // the Extended Key Usage extension.
  1011. #define CERTTYPE_PROP_EXTENDED_KEY_USAGE L"pKIExtendedKeyUsage"
  1012. // The list of default CSPs for this cert type
  1013. #define CERTTYPE_PROP_CSP_LIST L"pKIDefaultCSPs"
  1014. // The list of critical extensions
  1015. #define CERTTYPE_PROP_CRITICAL_EXTENSIONS L"pKICriticalExtensions"
  1016. // The major version of the templates
  1017. #define CERTTYPE_PROP_REVISION L"revision"
  1018. // The description of the templates
  1019. #define CERTTYPE_PROP_DESCRIPTION L"templateDescription"
  1020. //*****************************************************************************
  1021. //
  1022. // The schema version two properties
  1023. //
  1024. //*****************************************************************************
  1025. // The schema version of the templates
  1026. // This property is not settable
  1027. #define CERTTYPE_PROP_SCHEMA_VERSION L"msPKI-Template-Schema-Version"
  1028. // The minor version of the templates
  1029. #define CERTTYPE_PROP_MINOR_REVISION L"msPKI-Template-Minor-Revision"
  1030. // The number of RA signatures required on a request referencing this template.
  1031. #define CERTTYPE_PROP_RA_SIGNATURE L"msPKI-RA-Signature"
  1032. // The minimal key size required
  1033. #define CERTTYPE_PROP_MIN_KEY_SIZE L"msPKI-Minimal-Key-Size"
  1034. // The OID of this template
  1035. #define CERTTYPE_PROP_OID L"msPKI-Cert-Template-OID"
  1036. // The OID of the template that this template supersedes
  1037. #define CERTTYPE_PROP_SUPERSEDE L"msPKI-Supersede-Templates"
  1038. // The RA issuer policy OIDs required in certs used to sign a request.
  1039. // Each signing cert's szOID_CERT_POLICIES extensions must contain at least one
  1040. // of the OIDs listed in the msPKI-RA-Policies property.
  1041. // Each OID listed must appear in the szOID_CERT_POLICIES extension of at least
  1042. // one signing cert.
  1043. #define CERTTYPE_PROP_RA_POLICY L"msPKI-RA-Policies"
  1044. // The RA application policy OIDs required in certs used to sign a request.
  1045. // Each signing cert's szOID_APPLICATION_CERT_POLICIES extensions must contain
  1046. // all of the OIDs listed in the msPKI-RA-Application-Policies property.
  1047. #define CERTTYPE_PROP_RA_APPLICATION_POLICY L"msPKI-RA-Application-Policies"
  1048. // The certificate issuer policy OIDs are placed in the szOID_CERT_POLICIES
  1049. // extension by the policy module.
  1050. #define CERTTYPE_PROP_POLICY L"msPKI-Certificate-Policy"
  1051. // The certificate application policy OIDs are placed in the
  1052. // szOID_APPLICATION_CERT_POLICIES extension by the policy module.
  1053. #define CERTTYPE_PROP_APPLICATION_POLICY L"msPKI-Certificate-Application-Policy"
  1054. #define CERTTYPE_SCHEMA_VERSION_1 1
  1055. #define CERTTYPE_SCHEMA_VERSION_2 (CERTTYPE_SCHEMA_VERSION_1 + 1)
  1056. //
  1057. // CASetCertTypeProperty
  1058. // Set a property of a CertType. This function is obsolete.
  1059. // Use CASetCertTypePropertyEx.
  1060. //
  1061. // hCertType - Handle to an open CertType object.
  1062. //
  1063. // wszPropertyName - Name of the CertType property
  1064. //
  1065. // awszPropertyValue - An array of values to set for this property. The
  1066. // last element of this array should be NULL. For
  1067. // single valued properties, the values beyond the first
  1068. // will be ignored upon update.
  1069. //
  1070. // Returns - S_OK on success.
  1071. //
  1072. CERTCLIAPI
  1073. HRESULT
  1074. WINAPI
  1075. CASetCertTypeProperty(
  1076. IN HCERTTYPE hCertType,
  1077. IN LPCWSTR wszPropertyName,
  1078. IN LPWSTR * awszPropertyValue
  1079. );
  1080. //
  1081. // CASetCertTypePropertyEx
  1082. // Set a property of a CertType
  1083. //
  1084. // hCertType - Handle to an open CertType object.
  1085. //
  1086. // wszPropertyName - Name of the CertType property
  1087. //
  1088. // pPropertyValue - Depending on the value of wszPropertyName,
  1089. // pPropertyValue is either DWORD * or LPWSTR *.
  1090. //
  1091. // It is a DWORD * for:
  1092. // CERTTYPE_PROP_REVISION
  1093. // CERTTYPE_PROP_MINOR_REVISION
  1094. // CERTTYPE_PROP_RA_SIGNATURE
  1095. // CERTTYPE_PROP_MIN_KEY_SIZE
  1096. //
  1097. // It is a LPWSTR * for:
  1098. // CERTTYPE_PROP_FRIENDLY_NAME
  1099. // CERTTYPE_PROP_EXTENDED_KEY_USAGE
  1100. // CERTTYPE_PROP_CSP_LIST
  1101. // CERTTYPE_PROP_CRITICAL_EXTENSIONS
  1102. // CERTTYPE_PROP_OID
  1103. // CERTTYPE_PROP_SUPERSEDE
  1104. // CERTTYPE_PROP_RA_POLICY
  1105. // CERTTYPE_PROP_POLICY
  1106. //
  1107. // - An array of values to set for this property. The
  1108. // last element of this array should be NULL. For
  1109. // single valued properties, the values beyond the first
  1110. // will be ignored upon update.
  1111. //
  1112. //
  1113. // - CertType of V1 schema can only set V1 properties.
  1114. //
  1115. // Returns - S_OK on success.
  1116. //
  1117. CERTCLIAPI
  1118. HRESULT
  1119. WINAPI
  1120. CASetCertTypePropertyEx(
  1121. IN HCERTTYPE hCertType,
  1122. IN LPCWSTR wszPropertyName,
  1123. IN LPVOID pPropertyValue
  1124. );
  1125. //
  1126. // CAFreeCertTypeProperty
  1127. // Frees a previously retrieved property value.
  1128. //
  1129. // hCertType - Handle to an open CertType object.
  1130. //
  1131. // awszPropertyValue - The values to be freed.
  1132. //
  1133. CERTCLIAPI
  1134. HRESULT
  1135. WINAPI
  1136. CAFreeCertTypeProperty(
  1137. IN HCERTTYPE hCertType,
  1138. IN LPWSTR * awszPropertyValue
  1139. );
  1140. //
  1141. // CAGetCertTypeExtensions
  1142. // Retrieves the extensions associated with this CertType.
  1143. //
  1144. // hCertType - Handle to an open CertType object.
  1145. // ppCertExtensions - Pointer to a PCERT_EXTENSIONS to receive the result
  1146. // of this call. Should be freed via a
  1147. // CAFreeCertTypeExtensions call.
  1148. //
  1149. CERTCLIAPI
  1150. HRESULT
  1151. WINAPI
  1152. CAGetCertTypeExtensions(
  1153. IN HCERTTYPE hCertType,
  1154. OUT PCERT_EXTENSIONS * ppCertExtensions
  1155. );
  1156. //
  1157. // CAGetCertTypeExtensionsEx
  1158. // Retrieves the extensions associated with this CertType.
  1159. //
  1160. // hCertType - Handle to an open CertType object.
  1161. // dwFlags - Indicate which extension to be returned.
  1162. // Can be an ORing of following flags:
  1163. //
  1164. // CT_EXTENSION_TEMPLATE
  1165. // CT_EXTENSION_KEY_USAGE
  1166. // CT_EXTENSION_EKU
  1167. // CT_EXTENSION_BASIC_CONTRAINTS
  1168. // CT_EXTENSION_APPLICATION_POLICY (Version 2 template only)
  1169. // CT_EXTENSION_ISSUANCE_POLICY (Version 2 template only)
  1170. //
  1171. // 0 means all avaiable extension for this CertType.
  1172. //
  1173. // pParam - Reserved. Must be NULL.
  1174. // ppCertExtensions - Pointer to a PCERT_EXTENSIONS to receive the result
  1175. // of this call. Should be freed via a
  1176. // CAFreeCertTypeExtensions call.
  1177. //
  1178. CERTCLIAPI
  1179. HRESULT
  1180. WINAPI
  1181. CAGetCertTypeExtensionsEx(
  1182. IN HCERTTYPE hCertType,
  1183. IN DWORD dwFlags,
  1184. IN LPVOID pParam,
  1185. OUT PCERT_EXTENSIONS * ppCertExtensions
  1186. );
  1187. #define CT_EXTENSION_TEMPLATE 0x01
  1188. #define CT_EXTENSION_KEY_USAGE 0x02
  1189. #define CT_EXTENSION_EKU 0x04
  1190. #define CT_EXTENSION_BASIC_CONTRAINTS 0x08
  1191. #define CT_EXTENSION_APPLICATION_POLICY 0x10
  1192. #define CT_EXTENSION_ISSUANCE_POLICY 0x20
  1193. //
  1194. // CAFreeCertTypeExtensions
  1195. // Free a PCERT_EXTENSIONS allocated by CAGetCertTypeExtensions
  1196. //
  1197. CERTCLIAPI
  1198. HRESULT
  1199. WINAPI
  1200. CAFreeCertTypeExtensions(
  1201. IN HCERTTYPE hCertType,
  1202. IN PCERT_EXTENSIONS pCertExtensions
  1203. );
  1204. //
  1205. // CASetCertTypeExtension
  1206. // Set the value of an extension for this
  1207. // cert type.
  1208. //
  1209. // hCertType - handle to the CertType
  1210. //
  1211. // wszExtensionId - OID for the extension
  1212. //
  1213. // dwFlags - Mark the extension critical
  1214. //
  1215. // pExtension - pointer to the appropriate extension structure
  1216. //
  1217. // Supported extensions/structures
  1218. //
  1219. // szOID_ENHANCED_KEY_USAGE CERT_ENHKEY_USAGE
  1220. // szOID_KEY_USAGE CRYPT_BIT_BLOB
  1221. // szOID_BASIC_CONSTRAINTS2 CERT_BASIC_CONSTRAINTS2_INFO
  1222. //
  1223. // Returns S_OK if successful.
  1224. //
  1225. CERTCLIAPI
  1226. HRESULT
  1227. WINAPI
  1228. CASetCertTypeExtension(
  1229. IN HCERTTYPE hCertType,
  1230. IN LPCWSTR wszExtensionId,
  1231. IN DWORD dwFlags,
  1232. IN LPVOID pExtension
  1233. );
  1234. #define CA_EXT_FLAG_CRITICAL 0x00000001
  1235. //
  1236. // CAGetCertTypeFlags
  1237. // Retrieve cert type flags.
  1238. // This function is obsolete. Use CAGetCertTypeFlagsEx.
  1239. //
  1240. // hCertType - handle to the CertType
  1241. //
  1242. // pdwFlags - pointer to DWORD receiving flags
  1243. //
  1244. CERTCLIAPI
  1245. HRESULT
  1246. WINAPI
  1247. CAGetCertTypeFlags(
  1248. IN HCERTTYPE hCertType,
  1249. OUT DWORD * pdwFlags
  1250. );
  1251. //
  1252. // CAGetCertTypeFlagsEx
  1253. // Retrieve cert type flags
  1254. //
  1255. // hCertType - handle to the CertType
  1256. //
  1257. // dwOption - Which flag to set
  1258. // Can be one of the following:
  1259. // CERTTYPE_ENROLLMENT_FLAG
  1260. // CERTTYPE_SUBJECT_NAME_FLAG
  1261. // CERTTYPE_PRIVATE_KEY_FLAG
  1262. // CERTTYPE_GENERAL_FLAG
  1263. //
  1264. // pdwFlags - pointer to DWORD receiving flags
  1265. //
  1266. CERTCLIAPI
  1267. HRESULT
  1268. WINAPI
  1269. CAGetCertTypeFlagsEx(
  1270. IN HCERTTYPE hCertType,
  1271. IN DWORD dwOption,
  1272. OUT DWORD * pdwFlags
  1273. );
  1274. //*****************************************************************************
  1275. //
  1276. // Cert Type Flags
  1277. //
  1278. // The CertType flags are grouped into 4 categories:
  1279. // 1. Enrollment Flags (CERTTYPE_ENROLLMENT_FLAG)
  1280. // 2. Certificate Subject Name Flags (CERTTYPE_SUBJECT_NAME_FLAG)
  1281. // 3. Private Key Flags (CERTTYPE_PRIVATE_KEY_FLAG)
  1282. // 4. General Flags (CERTTYPE_GENERAL_FLAG)
  1283. //*****************************************************************************
  1284. //Enrollment Flags
  1285. #define CERTTYPE_ENROLLMENT_FLAG 0x01
  1286. //Certificate Subject Name Flags
  1287. #define CERTTYPE_SUBJECT_NAME_FLAG 0x02
  1288. //Private Key Flags
  1289. #define CERTTYPE_PRIVATE_KEY_FLAG 0x03
  1290. //General Flags
  1291. #define CERTTYPE_GENERAL_FLAG 0x04
  1292. //*****************************************************************************
  1293. //
  1294. // Enrollment Flags:
  1295. //
  1296. //*****************************************************************************
  1297. // Include the symmetric algorithms in the requests
  1298. #define CT_FLAG_INCLUDE_SYMMETRIC_ALGORITHMS 0x00000001
  1299. // All certificate requests are pended
  1300. #define CT_FLAG_PEND_ALL_REQUESTS 0x00000002
  1301. // Publish the certificate to the KRA (key recovery agent container) on the DS
  1302. #define CT_FLAG_PUBLISH_TO_KRA_CONTAINER 0x00000004
  1303. // Publish the resultant cert to the userCertificate property in the DS
  1304. #define CT_FLAG_PUBLISH_TO_DS 0x00000008
  1305. // The autoenrollment will not enroll for new certificate if user has a certificate
  1306. // published on the DS with the same template name
  1307. #define CT_FLAG_AUTO_ENROLLMENT_CHECK_USER_DS_CERTIFICATE 0x00000010
  1308. // This cert is appropriate for auto-enrollment
  1309. #define CT_FLAG_AUTO_ENROLLMENT 0x00000020
  1310. // A previously issued certificate will valid subsequent enrollment requests
  1311. #define CT_FLAG_PREVIOUS_APPROVAL_VALIDATE_REENROLLMENT 0x00000040
  1312. // Domain authentication is not required.
  1313. #define CT_FLAG_DOMAIN_AUTHENTICATION_NOT_REQUIRED 0x00000080
  1314. // User interaction is required to enroll
  1315. #define CT_FLAG_USER_INTERACTION_REQUIRED 0x00000100
  1316. // Add szOID_CERTTYPE_EXTENSION (template name) extension
  1317. // This flag will ONLY be set on V1 certificate templates for W2K CA only.
  1318. #define CT_FLAG_ADD_TEMPLATE_NAME 0x00000200
  1319. // Remove invalid (expired or revoked) certificate from personal store
  1320. #define CT_FLAG_REMOVE_INVALID_CERTIFICATE_FROM_PERSONAL_STORE 0x00000400
  1321. // Allow enroll-on-behalf-of; RA requirements still apply to signers
  1322. #define CT_FLAG_ALLOW_ENROLL_ON_BEHALF_OF 0x00000800
  1323. //*****************************************************************************
  1324. //
  1325. // Certificate Subject Name Flags:
  1326. //
  1327. //*****************************************************************************
  1328. // The enrolling application must supply the subject name.
  1329. #define CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT 0x00000001
  1330. // The enrolling application must supply the subjectAltName in request
  1331. #define CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT_ALT_NAME 0x00010000
  1332. // Subject name should be full DN
  1333. #define CT_FLAG_SUBJECT_REQUIRE_DIRECTORY_PATH 0x80000000
  1334. // Subject name should be the common name
  1335. #define CT_FLAG_SUBJECT_REQUIRE_COMMON_NAME 0x40000000
  1336. // Subject name includes the e-mail name
  1337. #define CT_FLAG_SUBJECT_REQUIRE_EMAIL 0x20000000
  1338. // Subject name includes the DNS name as the common name
  1339. #define CT_FLAG_SUBJECT_REQUIRE_DNS_AS_CN 0x10000000
  1340. // Subject alt name includes DNS name
  1341. #define CT_FLAG_SUBJECT_ALT_REQUIRE_DNS 0x08000000
  1342. // Subject alt name includes email name
  1343. #define CT_FLAG_SUBJECT_ALT_REQUIRE_EMAIL 0x04000000
  1344. // Subject alt name requires UPN
  1345. #define CT_FLAG_SUBJECT_ALT_REQUIRE_UPN 0x02000000
  1346. // Subject alt name requires directory GUID
  1347. #define CT_FLAG_SUBJECT_ALT_REQUIRE_DIRECTORY_GUID 0x01000000
  1348. // Subject alt name requires SPN
  1349. #define CT_FLAG_SUBJECT_ALT_REQUIRE_SPN 0x00800000
  1350. //
  1351. // Obsolete name
  1352. // The following flags are obsolete. They are used by V1 templates in the
  1353. // general flags
  1354. //
  1355. #define CT_FLAG_IS_SUBJECT_REQ CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT
  1356. // The e-mail name of the principal will be added to the cert
  1357. #define CT_FLAG_ADD_EMAIL 0x00000002
  1358. // Add the object GUID for this principal
  1359. #define CT_FLAG_ADD_OBJ_GUID 0x00000004
  1360. // Add DS Name (full DN) to szOID_SUBJECT_ALT_NAME2 (Subj Alt Name 2) extension
  1361. // This flag is not SET in any of the V1 templates and is of no interests to
  1362. // V2 templates since it is not present on the UI and will never be set.
  1363. #define CT_FLAG_ADD_DIRECTORY_PATH 0x00000100
  1364. //*****************************************************************************
  1365. //
  1366. // Private Key Flags:
  1367. //
  1368. //*****************************************************************************
  1369. // Archival of the private key is allowed
  1370. #define CT_FLAG_ALLOW_PRIVATE_KEY_ARCHIVAL 0x00000001
  1371. #define CT_FLAG_REQUIRE_PRIVATE_KEY_ARCHIVAL CT_FLAG_ALLOW_PRIVATE_KEY_ARCHIVAL
  1372. // Make the key for this cert exportable.
  1373. #define CT_FLAG_EXPORTABLE_KEY 0x00000010
  1374. // Require the strong key protection UI when a new key is generated
  1375. #define CT_FLAG_STRONG_KEY_PROTECTION_REQUIRED 0x00000020
  1376. //*****************************************************************************
  1377. //
  1378. // General Flags
  1379. //
  1380. // More flags should start from 0x00000400
  1381. //
  1382. //*****************************************************************************
  1383. // This is a machine cert type
  1384. #define CT_FLAG_MACHINE_TYPE 0x00000040
  1385. // This is a CA cert type
  1386. #define CT_FLAG_IS_CA 0x00000080
  1387. // This is a cross CA cert type
  1388. #define CT_FLAG_IS_CROSS_CA 0x00000800
  1389. // The type is a default cert type (cannot be set). This flag will be set on
  1390. // all V1 templates. The templates can not be edited or deleted.
  1391. #define CT_FLAG_IS_DEFAULT 0x00010000
  1392. // The type has been modified, if it is default (cannot be set)
  1393. #define CT_FLAG_IS_MODIFIED 0x00020000
  1394. // settable flags for general flags
  1395. #define CT_MASK_SETTABLE_FLAGS 0x0000ffff
  1396. //
  1397. // CASetCertTypeFlags
  1398. // Sets the General Flags of a cert type.
  1399. // This function is obsolete. Use CASetCertTypeFlagsEx.
  1400. //
  1401. // hCertType - handle to the CertType
  1402. //
  1403. // dwFlags - Flags to be set
  1404. //
  1405. CERTCLIAPI
  1406. HRESULT
  1407. WINAPI
  1408. CASetCertTypeFlags(
  1409. IN HCERTTYPE hCertType,
  1410. IN DWORD dwFlags
  1411. );
  1412. //
  1413. // CASetCertTypeFlagsEx
  1414. // Sets the Flags of a cert type
  1415. //
  1416. // hCertType - handle to the CertType
  1417. //
  1418. // dwOption - Which flag to set
  1419. // Can be one of the following:
  1420. // CERTTYPE_ENROLLMENT_FLAG
  1421. // CERTTYPE_SUBJECT_NAME_FLAG
  1422. // CERTTYPE_PRIVATE_KEY_FLAG
  1423. // CERTTYPE_GENERAL_FLAG
  1424. //
  1425. // dwFlags - Value to be set
  1426. //
  1427. CERTCLIAPI
  1428. HRESULT
  1429. WINAPI
  1430. CASetCertTypeFlagsEx(
  1431. IN HCERTTYPE hCertType,
  1432. IN DWORD dwOption,
  1433. IN DWORD dwFlags
  1434. );
  1435. //
  1436. // CAGetCertTypeKeySpec
  1437. // Retrieve the CAPI Key Spec for this cert type
  1438. //
  1439. // hCertType - handle to the CertType
  1440. //
  1441. // pdwKeySpec - pointer to DWORD receiving key spec
  1442. //
  1443. CERTCLIAPI
  1444. HRESULT
  1445. WINAPI
  1446. CAGetCertTypeKeySpec(
  1447. IN HCERTTYPE hCertType,
  1448. OUT DWORD * pdwKeySpec
  1449. );
  1450. //
  1451. // CACertTypeSetKeySpec
  1452. // Sets the CAPI1 Key Spec of a cert type
  1453. //
  1454. // hCertType - handle to the CertType
  1455. //
  1456. // dwKeySpec - KeySpec to be set
  1457. //
  1458. CERTCLIAPI
  1459. HRESULT
  1460. WINAPI
  1461. CASetCertTypeKeySpec(
  1462. IN HCERTTYPE hCertType,
  1463. IN DWORD dwKeySpec
  1464. );
  1465. //
  1466. // CAGetCertTypeExpiration
  1467. // Retrieve the Expiration Info for this cert type
  1468. //
  1469. // pftExpiration - pointer to the FILETIME structure receiving
  1470. // the expiration period for this cert type.
  1471. //
  1472. // pftOverlap - pointer to the FILETIME structure receiving the
  1473. // suggested renewal overlap period for this cert type.
  1474. //
  1475. CERTCLIAPI
  1476. HRESULT
  1477. WINAPI
  1478. CAGetCertTypeExpiration(
  1479. IN HCERTTYPE hCertType,
  1480. OUT OPTIONAL FILETIME * pftExpiration,
  1481. OUT OPTIONAL FILETIME * pftOverlap
  1482. );
  1483. //
  1484. // CASetCertTypeExpiration
  1485. // Set the Expiration Info for this cert type
  1486. //
  1487. // pftExpiration - pointer to the FILETIME structure containing
  1488. // the expiration period for this cert type.
  1489. //
  1490. // pftOverlap - pointer to the FILETIME structure containing the
  1491. // suggested renewal overlap period for this cert type.
  1492. //
  1493. CERTCLIAPI
  1494. HRESULT
  1495. WINAPI
  1496. CASetCertTypeExpiration(
  1497. IN HCERTTYPE hCertType,
  1498. IN OPTIONAL FILETIME * pftExpiration,
  1499. IN OPTIONAL FILETIME * pftOverlap
  1500. );
  1501. //
  1502. // CACertTypeSetSecurity
  1503. // Set the list of Users, Groups, and Machines allowed
  1504. // to access this cert type.
  1505. //
  1506. // hCertType - handle to the CertType
  1507. //
  1508. // pSD - Security descriptor for this cert type
  1509. //
  1510. CERTCLIAPI
  1511. HRESULT
  1512. WINAPI
  1513. CACertTypeSetSecurity(
  1514. IN HCERTTYPE hCertType,
  1515. IN PSECURITY_DESCRIPTOR pSD
  1516. );
  1517. //
  1518. // CACertTypeGetSecurity
  1519. // Get the list of Users, Groups, and Machines allowed
  1520. // to access this cert type.
  1521. //
  1522. // hCertType - handle to the CertType
  1523. //
  1524. // ppaSidList - Pointer to a location receiving the pointer to the
  1525. // security descriptor. Free via LocalFree.
  1526. //
  1527. CERTCLIAPI
  1528. HRESULT
  1529. WINAPI
  1530. CACertTypeGetSecurity(
  1531. IN HCERTTYPE hCertType,
  1532. OUT PSECURITY_DESCRIPTOR * ppSD
  1533. );
  1534. //
  1535. //
  1536. // CACertTypeAccessCheck
  1537. // Determine whether the principal specified by
  1538. // ClientToken can be issued this cert type.
  1539. //
  1540. // hCertType - handle to the CertType
  1541. //
  1542. // ClientToken - Handle to an impersonation token that represents the
  1543. // client attempting to request this cert type. The
  1544. // handle must have TOKEN_QUERY access to the token;
  1545. // otherwise, the call fails with ERROR_ACCESS_DENIED.
  1546. //
  1547. // Return: S_OK on success
  1548. //
  1549. CERTCLIAPI
  1550. HRESULT
  1551. WINAPI
  1552. CACertTypeAccessCheck(
  1553. IN HCERTTYPE hCertType,
  1554. IN HANDLE ClientToken
  1555. );
  1556. //
  1557. //
  1558. // CACertTypeAccessCheckEx
  1559. // Determine whether the principal specified by
  1560. // ClientToken can be issued this cert type.
  1561. //
  1562. // hCertType - handle to the CertType
  1563. //
  1564. // ClientToken - Handle to an impersonation token that represents the
  1565. // client attempting to request this cert type. The
  1566. // handle must have TOKEN_QUERY access to the token;
  1567. // otherwise, the call fails with ERROR_ACCESS_DENIED.
  1568. //
  1569. // dwOption - Can be one of the following:
  1570. // CERTTYPE_ACCESS_CHECK_ENROLL
  1571. // CERTTYPE_ACCESS_CHECK_AUTO_ENROLL
  1572. //
  1573. // dwOption can be ORed with CERTTYPE_ACCESS_CHECK_NO_MAPPING
  1574. // to disallow default mapping of client token
  1575. //
  1576. // Return: S_OK on success
  1577. //
  1578. CERTCLIAPI
  1579. HRESULT
  1580. WINAPI
  1581. CACertTypeAccessCheckEx(
  1582. IN HCERTTYPE hCertType,
  1583. IN HANDLE ClientToken,
  1584. IN DWORD dwOption
  1585. );
  1586. #define CERTTYPE_ACCESS_CHECK_ENROLL 0x01
  1587. #define CERTTYPE_ACCESS_CHECK_AUTO_ENROLL 0x02
  1588. #define CERTTYPE_ACCESS_CHECK_NO_MAPPING 0x00010000
  1589. //
  1590. //
  1591. // CAInstallDefaultCertType
  1592. //
  1593. // Install default certificate types on the enterprise.
  1594. //
  1595. // dwFlags - Reserved. Must be 0 for now
  1596. //
  1597. //
  1598. // Return: S_OK on success
  1599. //
  1600. CERTCLIAPI
  1601. HRESULT
  1602. WINAPI
  1603. CAInstallDefaultCertType(
  1604. IN DWORD dwFlags
  1605. );
  1606. //
  1607. //
  1608. // CAIsCertTypeCurrent
  1609. //
  1610. // Check if the certificate type on the DS is up to date
  1611. //
  1612. // dwFlags - Reserved. Must be 0 for now
  1613. // wszCertType - The name for the certificate type
  1614. //
  1615. // Return: TRUE if the cert type is update to date
  1616. //
  1617. CERTCLIAPI
  1618. BOOL
  1619. WINAPI
  1620. CAIsCertTypeCurrent(
  1621. IN DWORD dwFlags,
  1622. IN LPWSTR wszCertType
  1623. );
  1624. //*****************************************************************************
  1625. //
  1626. // OID management APIs
  1627. //
  1628. //*****************************************************************************
  1629. //
  1630. // CAOIDCreateNew
  1631. // Create a new OID based on the enterprise base
  1632. //
  1633. // dwType - Can be one of the following:
  1634. // CERT_OID_TYPE_TEMPLATE
  1635. // CERT_OID_TYPE_ISSUER_POLICY
  1636. // CERT_OID_TYPE_APPLICATION_POLICY
  1637. //
  1638. // dwFlag - Reserved. Must be 0.
  1639. //
  1640. // ppwszOID - Return the new OID. Free memory via LocalFree().
  1641. //
  1642. // Returns S_OK if successful.
  1643. //
  1644. CERTCLIAPI
  1645. HRESULT
  1646. WINAPI
  1647. CAOIDCreateNew(
  1648. IN DWORD dwType,
  1649. IN DWORD dwFlag,
  1650. OUT LPWSTR *ppwszOID);
  1651. #define CERT_OID_TYPE_TEMPLATE 0x01
  1652. #define CERT_OID_TYPE_ISSUER_POLICY 0x02
  1653. #define CERT_OID_TYPE_APPLICATION_POLICY 0x03
  1654. //
  1655. // CAOIDAdd
  1656. // Add an OID to the DS repository
  1657. //
  1658. // dwType - Can be one of the following:
  1659. // CERT_OID_TYPE_TEMPLATE
  1660. // CERT_OID_TYPE_ISSUER_POLICY
  1661. // CERT_OID_TYPE_APPLICATION_POLICY
  1662. //
  1663. // dwFlag - Reserved. Must be 0.
  1664. //
  1665. // pwszOID - The OID to add.
  1666. //
  1667. // Returns S_OK if successful.
  1668. // Returns CRYPT_E_EXISTS if the OID alreay exits in the DS repository
  1669. //
  1670. CERTCLIAPI
  1671. HRESULT
  1672. WINAPI
  1673. CAOIDAdd(
  1674. IN DWORD dwType,
  1675. IN DWORD dwFlag,
  1676. IN LPCWSTR pwszOID);
  1677. //
  1678. // CAOIDDelete
  1679. // Delete the OID from the DS repository
  1680. //
  1681. // pwszOID - The OID to delete.
  1682. //
  1683. // Returns S_OK if successful.
  1684. //
  1685. CERTCLIAPI
  1686. HRESULT
  1687. WINAPI
  1688. CAOIDDelete(
  1689. IN LPCWSTR pwszOID);
  1690. //
  1691. // CAOIDSetProperty
  1692. // Set a property on an OID.
  1693. //
  1694. // pwszOID - The OID whose value is set
  1695. // dwProperty - The property name. Can be one of the following:
  1696. // CERT_OID_PROPERTY_DISPLAY_NAME
  1697. // CERT_OID_PROPERTY_CPS
  1698. //
  1699. // pPropValue - The value of the property.
  1700. // If dwProperty is CERT_OID_PROPERTY_DISPLAY_NAME,
  1701. // pPropValue is LPWSTR.
  1702. // if dwProperty is CERT_OID_PROPERTY_CPS,
  1703. // pPropValue is LPWSTR.
  1704. // NULL will remove the property
  1705. //
  1706. //
  1707. // Returns S_OK if successful.
  1708. //
  1709. CERTCLIAPI
  1710. HRESULT
  1711. WINAPI
  1712. CAOIDSetProperty(
  1713. IN LPCWSTR pwszOID,
  1714. IN DWORD dwProperty,
  1715. IN LPVOID pPropValue);
  1716. #define CERT_OID_PROPERTY_DISPLAY_NAME 0x01
  1717. #define CERT_OID_PROPERTY_CPS 0x02
  1718. #define CERT_OID_PROPERTY_TYPE 0x03
  1719. //
  1720. // CAOIDGetProperty
  1721. // Get a property on an OID.
  1722. //
  1723. // pwszOID - The OID whose value is queried
  1724. // dwProperty - The property name. Can be one of the following:
  1725. // CERT_OID_PROPERTY_DISPLAY_NAME
  1726. // CERT_OID_PROPERTY_CPS
  1727. // CERT_OID_PROPERTY_TYPE
  1728. //
  1729. // pPropValue - The value of the property.
  1730. // If dwProperty is CERT_OID_PROPERTY_DISPLAY_NAME,
  1731. // pPropValue is LPWSTR *.
  1732. // if dwProperty is CERT_OID_PROPERTY_CPS, pPropValue is
  1733. // LPWSTR *.
  1734. //
  1735. // Free the above properties via CAOIDFreeProperty().
  1736. //
  1737. // If dwProperty is CERT_OID_PROPERTY_TYPE, pPropValue
  1738. // is DWORD *.
  1739. //
  1740. // Returns S_OK if successful.
  1741. //
  1742. CERTCLIAPI
  1743. HRESULT
  1744. WINAPI
  1745. CAOIDGetProperty(
  1746. IN LPCWSTR pwszOID,
  1747. IN DWORD dwProperty,
  1748. OUT LPVOID pPropValue);
  1749. //
  1750. // CAOIDFreeProperty
  1751. // Free a property returned from CAOIDGetProperty
  1752. //
  1753. // pPropValue - The value of the property.
  1754. //
  1755. // Returns S_OK if successful.
  1756. //
  1757. CERTCLIAPI
  1758. HRESULT
  1759. WINAPI
  1760. CAOIDFreeProperty(
  1761. IN LPVOID pPropValue);
  1762. //
  1763. // CAOIDGetLdapURL
  1764. //
  1765. // Return the LDAP URL for OID repository. In the format of
  1766. // LDAP:///DN of the Repository/all attributes?one?filter. The filter
  1767. // is determined by dwType.
  1768. //
  1769. // dwType - Can be one of the following:
  1770. // CERT_OID_TYPE_TEMPLATE
  1771. // CERT_OID_TYPE_ISSUER_POLICY
  1772. // CERT_OID_TYPE_APPLICATION_POLICY
  1773. // CERT_OID_TYPE_ALL
  1774. //
  1775. // dwFlag - Reserved. Must be 0.
  1776. //
  1777. // ppwszURL - Return the URL. Free memory via CAOIDFreeLdapURL.
  1778. //
  1779. // Returns S_OK if successful.
  1780. //
  1781. CERTCLIAPI
  1782. HRESULT
  1783. WINAPI
  1784. CAOIDGetLdapURL(
  1785. IN DWORD dwType,
  1786. IN DWORD dwFlag,
  1787. OUT LPWSTR *ppwszURL);
  1788. #define CERT_OID_TYPE_ALL 0x0
  1789. //
  1790. // CAOIDFreeLDAPURL
  1791. // Free the URL returned from CAOIDGetLdapURL
  1792. //
  1793. // pwszURL - The URL returned from CAOIDGetLdapURL
  1794. //
  1795. // Returns S_OK if successful.
  1796. //
  1797. CERTCLIAPI
  1798. HRESULT
  1799. WINAPI
  1800. CAOIDFreeLdapURL(
  1801. IN LPCWSTR pwszURL);
  1802. //the LDAP properties for OID class
  1803. #define OID_PROP_TYPE L"flags"
  1804. #define OID_PROP_OID L"msPKI-Cert-Template-OID"
  1805. #define OID_PROP_DISPLAY_NAME L"displayName"
  1806. #define OID_PROP_CPS L"msPKI-OID-CPS"
  1807. #define OID_PROP_LOCALIZED_NAME L"msPKI-OIDLocalizedName"
  1808. //*****************************************************************************
  1809. //
  1810. // Cert Type Change Query APIS
  1811. //
  1812. //*****************************************************************************
  1813. //
  1814. // CACertTypeRegisterQuery
  1815. //
  1816. // Regiser the calling thread to query if any modification has happened
  1817. // to cert type information on the directory
  1818. //
  1819. //
  1820. // dwFlag - Reserved. Must be 0.
  1821. //
  1822. // pvldap - The LDAP handle to the directory (LDAP *). Optional input.
  1823. // If pvldap is not NULL, then the caller has to call
  1824. // CACertTypeUnregisterQuery before unbind the pldap.
  1825. //
  1826. // pHCertTypeQuery - Receive the HCERTTYPEQUERY handle upon success.
  1827. //
  1828. // Returns S_OK if successful.
  1829. //
  1830. //
  1831. CERTCLIAPI
  1832. HRESULT
  1833. WINAPI
  1834. CACertTypeRegisterQuery(
  1835. IN DWORD dwFlag,
  1836. IN LPVOID pvldap,
  1837. OUT HCERTTYPEQUERY *phCertTypeQuery);
  1838. //
  1839. // CACertTypeQuery
  1840. //
  1841. // Returns a change sequence number which is incremented by 1 whenever
  1842. // cert type information on the directory is changed.
  1843. //
  1844. // hCertTypeQuery - The hCertTypeQuery returned from previous
  1845. // CACertTypeRegisterQuery calls.
  1846. //
  1847. // *pdwChangeSequence - Returns a DWORD, which is incremented by 1
  1848. // whenever any changes has happened to cert type
  1849. // information on the directory since the last
  1850. // call to CACertTypeRegisterQuery or CACertTypeQuery.
  1851. //
  1852. //
  1853. //
  1854. // Returns S_OK if successful.
  1855. //
  1856. //
  1857. CERTCLIAPI
  1858. HRESULT
  1859. WINAPI
  1860. CACertTypeQuery(
  1861. IN HCERTTYPEQUERY hCertTypeQuery,
  1862. OUT DWORD *pdwChangeSequence);
  1863. //
  1864. // CACertTypeUnregisterQuery
  1865. //
  1866. // Unregister the calling thread to query if any modification has happened
  1867. // to cert type information on the directory
  1868. //
  1869. //
  1870. // hCertTypeQuery - The hCertTypeQuery returned from previous
  1871. // CACertTypeRegisterQuery calls.
  1872. //
  1873. // Returns S_OK if successful.
  1874. //
  1875. //
  1876. CERTCLIAPI
  1877. HRESULT
  1878. WINAPI
  1879. CACertTypeUnregisterQuery(
  1880. IN HCERTTYPEQUERY hCertTypeQuery);
  1881. //*****************************************************************************
  1882. //
  1883. // Autoenrollment APIs
  1884. //
  1885. //*****************************************************************************
  1886. //
  1887. // CACreateLocalAutoEnrollmentObject
  1888. // Create an auto-enrollment object on the local machine.
  1889. //
  1890. // pwszCertType - The name of the certificate type for which to create the
  1891. // auto-enrollment object
  1892. //
  1893. // awszCAs - The list of CAs to add to the auto-enrollment object with the
  1894. // last entry in the list being NULL. If the list is NULL or
  1895. // empty, then it create an auto-enrollment object which
  1896. // instructs the system to enroll for a cert at any CA
  1897. // supporting the requested certificate type.
  1898. //
  1899. // pSignerInfo - not used, must be NULL.
  1900. //
  1901. // dwFlags - can be CERT_SYSTEM_STORE_CURRENT_USER or
  1902. // CERT_SYSTEM_STORE_LOCAL_MACHINE, indicating auto-enrollment
  1903. // store in which the auto-enrollment object is created.
  1904. //
  1905. // Return: S_OK on success.
  1906. //
  1907. CERTCLIAPI
  1908. HRESULT
  1909. WINAPI
  1910. CACreateLocalAutoEnrollmentObject(
  1911. IN LPCWSTR pwszCertType,
  1912. IN OPTIONAL WCHAR ** awszCAs,
  1913. IN OPTIONAL PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1914. IN DWORD dwFlags);
  1915. //
  1916. // CADeleteLocalAutoEnrollmentObject
  1917. // Delete an auto-enrollment object on the local machine.
  1918. //
  1919. // pwszCertType - The name of the certificate type for which to delete the
  1920. // auto-enrollment object
  1921. //
  1922. // awszCAs - not used. must be NULL. All callers to CACreateLocalAutoEnrollmentObject
  1923. // have supplied NULL.
  1924. //
  1925. // pSignerInfo - not used, must be NULL.
  1926. //
  1927. // dwFlags - can be CERT_SYSTEM_STORE_CURRENT_USER or
  1928. // CERT_SYSTEM_STORE_LOCAL_MACHINE, indicating auto-enrollment
  1929. // store in which the auto-enrollment object is deleted.
  1930. //
  1931. // Return: S_OK on success.
  1932. //
  1933. CERTCLIAPI
  1934. HRESULT
  1935. WINAPI
  1936. CADeleteLocalAutoEnrollmentObject(
  1937. IN LPCWSTR pwszCertType,
  1938. IN OPTIONAL WCHAR ** awszCAs,
  1939. IN OPTIONAL PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1940. IN DWORD dwFlags);
  1941. //
  1942. // CACreateAutoEnrollmentObjectEx
  1943. // Create an auto-enrollment object in the indicated store.
  1944. //
  1945. // pwszCertType - The name of the certificate type for which to create the
  1946. // auto-enrollment object
  1947. //
  1948. // pwszObjectID - An identifying string for this autoenrollment object. NULL
  1949. // may be passed if this object is simply to be identified by
  1950. // its certificate template. An autoenrollment object is
  1951. // identified by a combination of its object id and its cert
  1952. // type name.
  1953. //
  1954. // awszCAs - The list of CAs to add to the auto-enrollment object, with
  1955. // the last entry in the list being NULL. If the list is NULL
  1956. // or empty, then it create an auto-enrollment object which
  1957. // instructs the system to enroll for a cert at any CA
  1958. // supporting the requested certificate type.
  1959. //
  1960. // pSignerInfo - not used, must be NULL.
  1961. //
  1962. // StoreProvider - see CertOpenStore
  1963. //
  1964. // dwFlags - see CertOpenStore
  1965. //
  1966. // pvPara - see CertOpenStore
  1967. //
  1968. // Return: S_OK on success.
  1969. //
  1970. //
  1971. CERTCLIAPI
  1972. HRESULT
  1973. WINAPI
  1974. CACreateAutoEnrollmentObjectEx(
  1975. IN LPCWSTR pwszCertType,
  1976. IN LPCWSTR wszObjectID,
  1977. IN WCHAR ** awszCAs,
  1978. IN PCMSG_SIGNED_ENCODE_INFO pSignerInfo,
  1979. IN LPCSTR StoreProvider,
  1980. IN DWORD dwFlags,
  1981. IN const void * pvPara);
  1982. typedef struct _CERTSERVERENROLL
  1983. {
  1984. DWORD Disposition;
  1985. HRESULT hrLastStatus;
  1986. DWORD RequestId;
  1987. BYTE *pbCert;
  1988. DWORD cbCert;
  1989. BYTE *pbCertChain;
  1990. DWORD cbCertChain;
  1991. WCHAR *pwszDispositionMessage;
  1992. } CERTSERVERENROLL;
  1993. //*****************************************************************************
  1994. //
  1995. // Cert Server RPC interfaces:
  1996. //
  1997. //*****************************************************************************
  1998. CERTCLIAPI
  1999. HRESULT
  2000. WINAPI
  2001. CertServerSubmitRequest(
  2002. IN DWORD Flags,
  2003. IN BYTE const *pbRequest,
  2004. IN DWORD cbRequest,
  2005. OPTIONAL IN WCHAR const *pwszRequestAttributes,
  2006. IN WCHAR const *pwszServerName,
  2007. IN WCHAR const *pwszAuthority,
  2008. OUT CERTSERVERENROLL **ppcsEnroll); // free via CertServerFreeMemory
  2009. CERTCLIAPI
  2010. HRESULT
  2011. WINAPI
  2012. CertServerRetrievePending(
  2013. IN DWORD RequestId,
  2014. OPTIONAL IN WCHAR const *pwszSerialNumber,
  2015. IN WCHAR const *pwszServerName,
  2016. IN WCHAR const *pwszAuthority,
  2017. OUT CERTSERVERENROLL **ppcsEnroll); // free via CertServerFreeMemory
  2018. CERTCLIAPI
  2019. VOID
  2020. WINAPI
  2021. CertServerFreeMemory(
  2022. IN VOID *pv);
  2023. enum ENUM_PERIOD
  2024. {
  2025. ENUM_PERIOD_INVALID = -1,
  2026. ENUM_PERIOD_SECONDS = 0,
  2027. ENUM_PERIOD_MINUTES,
  2028. ENUM_PERIOD_HOURS,
  2029. ENUM_PERIOD_DAYS,
  2030. ENUM_PERIOD_WEEKS,
  2031. ENUM_PERIOD_MONTHS,
  2032. ENUM_PERIOD_YEARS
  2033. };
  2034. typedef struct _PERIODUNITS
  2035. {
  2036. LONG lCount;
  2037. enum ENUM_PERIOD enumPeriod;
  2038. } PERIODUNITS;
  2039. HRESULT
  2040. caTranslateFileTimePeriodToPeriodUnits(
  2041. IN FILETIME const *pftGMT,
  2042. IN BOOL fExact,
  2043. OUT DWORD *pcPeriodUnits,
  2044. OUT PERIODUNITS **prgPeriodUnits);
  2045. #ifdef __cplusplus
  2046. }
  2047. #endif
  2048. #endif //__CERTCA_H__