//+--------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1996 - 1999
//
// File:        certcli.idl
//
// Contents:    IDL source for certcli.dll
//
//---------------------------------------------------------------------------

// This file will be processed by the MIDL tool to produce the type library
// (certcli.tlb) and marshalling code.

import "wtypes.idl";
import "certif.idl";
import "oaidl.idl";

//+--------------------------------------------------------------------------
// ICertGetConfig -- local COM interface, local implementation
//+--------------------------------------------------------------------------

[
    object,
    uuid(c7ea09c0-ce17-11d0-8833-00a0c903b83c),
    dual,
    helpstring("ICertGetConfig Interface"),
    pointer_default(unique)
]

interface ICertGetConfig: IDispatch
{
    HRESULT GetConfig(
		[in] LONG Flags,
		[out, retval] BSTR *pstrOut);
};


//+--------------------------------------------------------------------------
// ICertConfig::GetField()
// strFieldName parameter values:

     cpp_quote("#define wszCONFIG_COMMONNAME 		L\"CommonName\"")
     cpp_quote("#define wszCONFIG_ORGUNIT 		L\"OrgUnit\"")
     cpp_quote("#define wszCONFIG_ORGANIZATION 		L\"Organization\"")
     cpp_quote("#define wszCONFIG_LOCALITY 		L\"Locality\"")
     cpp_quote("#define wszCONFIG_STATE			L\"State\"")
     cpp_quote("#define wszCONFIG_COUNTRY		L\"Country\"")
     cpp_quote("#define wszCONFIG_CONFIG		L\"Config\"")
     cpp_quote("#define wszCONFIG_EXCHANGECERTIFICATE	L\"ExchangeCertificate\"")
     cpp_quote("#define wszCONFIG_SIGNATURECERTIFICATE	L\"SignatureCertificate\"")
     cpp_quote("#define wszCONFIG_DESCRIPTION		L\"Description\"")
     cpp_quote("#define wszCONFIG_COMMENT		L\"Comment\" // obsolete: use Description")
     cpp_quote("#define wszCONFIG_SERVER 		L\"Server\"")
     cpp_quote("#define wszCONFIG_AUTHORITY 		L\"Authority\"")
     cpp_quote("#define wszCONFIG_SANITIZEDNAME		L\"SanitizedName\"")
     cpp_quote("#define wszCONFIG_SHORTNAME		L\"ShortName\"")
     cpp_quote("#define wszCONFIG_SANITIZEDSHORTNAME	L\"SanitizedShortName\"")
     cpp_quote("#define wszCONFIG_FLAGS			L\"Flags\"")


// Flags setting
const LONG CAIF_DSENTRY           = 0x00000001;	// bit set for CA from DS
const LONG CAIF_SHAREDFOLDERENTRY = 0x00000002;	// CA from shared folder
const LONG CAIF_REGISTRY          = 0x00000004;	// CA from local registry
const LONG CAIF_LOCAL             = 0x00000008;	// local CA
const LONG CAIF_REGISTRYPARENT    = 0x00000010;	// CA parent from registry

//+--------------------------------------------------------------------------
// ICertConfig -- local COM interface, local implementation
//+--------------------------------------------------------------------------

[
    object,
    uuid(372fce34-4324-11d0-8810-00a0c903b83c),
    dual,
    helpstring("ICertConfig Interface"),
    pointer_default(unique)
]

interface ICertConfig: IDispatch
{
    HRESULT Reset(
		[in] LONG Index,
		[out, retval] LONG *pCount);

    HRESULT Next(
		[out, retval] LONG *pIndex);

    HRESULT GetField(
		[in] BSTR const strFieldName,
		[out, retval] BSTR *pstrOut);

    HRESULT GetConfig(
		[in] LONG Flags,
		[out, retval] BSTR *pstrOut);
};


//+--------------------------------------------------------------------------
// ICertConfig2 -- local COM interface, local implementation
//+--------------------------------------------------------------------------

[
    object,
    uuid(7a18edde-7e78-4163-8ded-78e2c9cee924),
    dual,
    helpstring("ICertConfig2 Interface"),
    pointer_default(unique)
]

interface ICertConfig2: ICertConfig
{
    HRESULT SetSharedFolder(
		[in] BSTR const strSharedFolder);
};


//+--------------------------------------------------------------------------
// ICertRequest::Submit()
// Flags for request and attributes encoding and type:

const LONG CR_IN_BASE64HEADER = 0x00000000;	// BASE64 with begin/end
const LONG CR_IN_BASE64 =       0x00000001;	// BASE64 w/o begin/end
const LONG CR_IN_BINARY =       0x00000002;	// binary request
const LONG CR_IN_ENCODEANY =	0x000000ff; 	// Could be any of the above
const LONG CR_IN_ENCODEMASK =	0x000000ff;	// request encoding mask

const LONG CR_IN_FORMATANY =	0x00000000; 	// Could be any of the below
const LONG CR_IN_PKCS10 =	0x00000100; 	// PKCS 10 request
const LONG CR_IN_KEYGEN =	0x00000200; 	// Keygen request
const LONG CR_IN_PKCS7 =	0x00000300; 	// PKCS 7 renewal request
const LONG CR_IN_CMC =		0x00000400; 	// CMC request
const LONG CR_IN_FORMATMASK =	0x0000ff00;	// request format mask

// Cert Server 1.0 obsolete encryption bits:
//const LONG CR_IN_ENCRYPTED_REQUEST =    0x00010000; // request encrypted
//const LONG CR_IN_ENCRYPTED_ATTRIBUTES = 0x00020000; // attributes encrypted
const LONG CR_IN_RPC =          0x00020000;	// Use RPC instead of DCOM
const LONG CR_IN_FULLRESPONSE = 0x00040000;	// Return CMC Full Response
const LONG CR_IN_CRLS =	 	0x00080000;	// include current CRLs

// Flags for GetConfig flag
const LONG CC_DEFAULTCONFIG =     0x00000000; // ask to get 1st pingable CA
const LONG CC_UIPICKCONFIG =      0x00000001; // invoke UI to pick CA
const LONG CC_FIRSTCONFIG =       0x00000002; // pick first CA
const LONG CC_LOCALCONFIG =       0x00000003; // pick local CA
const LONG CC_LOCALACTIVECONFIG = 0x00000004; // pick local pingable CA
const LONG CC_UIPICKCONFIGSKIPLOCALCA = 0x00000005; // UI to pick non-local CA

//+--------------------------------------------------------------------------
// ICertRequest::Submit(), ICertRequest::RetrievePending() and
// returned Disposition:

const LONG CR_DISP_INCOMPLETE =		0x00000000; // request did not complete
const LONG CR_DISP_ERROR =		0x00000001; // request failed
const LONG CR_DISP_DENIED =		0x00000002; // request denied
const LONG CR_DISP_ISSUED =		0x00000003; // cert issued
const LONG CR_DISP_ISSUED_OUT_OF_BAND = 0x00000004; // cert issued separately
const LONG CR_DISP_UNDER_SUBMISSION =   0x00000005; // taken under submission
const LONG CR_DISP_REVOKED =	        0x00000006; // issued and revoked


//+--------------------------------------------------------------------------
// ICertRequest::GetCACertificate(),
// ICertRequest::GetCertificate(),
// ICertAdmin::GetCRL(),
// ICertRequest2::GetCAProperty(),
// ICertAdmin2::GetCAProperty()
// ICertRequest2::GetFullResponseProperty(),
// Flags for certificate encoding:

const LONG CR_OUT_BASE64HEADER = 0x00000000;	// BASE64 with begin/end
const LONG CR_OUT_BASE64 =       0x00000001;	// BASE64 w/o begin/end
const LONG CR_OUT_BINARY =       0x00000002;	// binary certificate
const LONG CR_OUT_ENCODEMASK =	 0x000000ff;	// certificate encoding mask
const LONG CR_OUT_CHAIN =	 0x00000100;	// return certificate chain
const LONG CR_OUT_CRLS =	 0x00000200;	// chain with current CRLs


//+--------------------------------------------------------------------------
// ICertRequest2::GetErrorMessageText() Flags 

const LONG CR_GEMT_HRESULT_STRING = 0x00000001;	// Append "0xXX (Win32: DD)"


//+--------------------------------------------------------------------------
// ICertRequest2::GetCAProperty(), ICertAdmin2::GetCAProperty() PropId

cpp_quote("#define CR_PROP_NONE               0  // Invalid")
cpp_quote("#define CR_PROP_FILEVERSION        1  // String")
cpp_quote("#define CR_PROP_PRODUCTVERSION     2  // String")
cpp_quote("#define CR_PROP_EXITCOUNT          3  // Long")
cpp_quote("")
cpp_quote("// CR_PROP_EXITCOUNT Elements:")
cpp_quote("#define CR_PROP_EXITDESCRIPTION    4  // String, Indexed")
cpp_quote("")
cpp_quote("#define CR_PROP_POLICYDESCRIPTION  5  // String")
cpp_quote("#define CR_PROP_CANAME             6  // String")
cpp_quote("#define CR_PROP_SANITIZEDCANAME    7  // String")
cpp_quote("#define CR_PROP_SHAREDFOLDER       8  // String")
cpp_quote("#define CR_PROP_PARENTCA           9  // String")

cpp_quote("#define CR_PROP_CATYPE            10  // Long")
cpp_quote("#define CR_PROP_CASIGCERTCOUNT    11  // Long")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CASIGCERT         12  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CASIGCERTCHAIN    13  // Binary, Indexed")
cpp_quote("")
cpp_quote("#define CR_PROP_CAXCHGCERTCOUNT   14  // Long")
cpp_quote("")
cpp_quote("// CR_PROP_CAXCHGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CAXCHGCERT        15  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CAXCHGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CAXCHGCERTCHAIN   16  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("// Fetch only if CR_PROP_CRLSTATE[i] == CA_DISP_VALID")
cpp_quote("// May also be available if CR_PROP_CRLSTATE[i] == CA_DISP_INVALID")
cpp_quote("#define CR_PROP_BASECRL           17  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("// Fetch only if Delta CRLs enabled && CR_PROP_CRLSTATE[i] == CA_DISP_VALID")
cpp_quote("// May also be available if CR_PROP_CRLSTATE[i] == CA_DISP_INVALID")
cpp_quote("#define CR_PROP_DELTACRL          18  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CACERTSTATE       19  // Long, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CRLSTATE          20  // Long, Indexed")
cpp_quote("")
cpp_quote("#define CR_PROP_CAPROPIDMAX       21  // Long")
cpp_quote("#define CR_PROP_DNSNAME           22  // String")
cpp_quote("#define CR_PROP_ROLESEPARATIONENABLED 23 // Long")
cpp_quote("#define CR_PROP_KRACERTUSEDCOUNT  24  // Long")
cpp_quote("#define CR_PROP_KRACERTCOUNT      25  // Long")
cpp_quote("")
cpp_quote("// CR_PROP_KRACERTCOUNT Elements:")
cpp_quote("#define CR_PROP_KRACERT           26  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_KRACERTCOUNT Elements:")
cpp_quote("#define CR_PROP_KRACERTSTATE      27  // Long, Indexed")
cpp_quote("")
cpp_quote("#define CR_PROP_ADVANCEDSERVER    28  // Long")
cpp_quote("#define CR_PROP_TEMPLATES         29  // String")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("// Fetch only if CR_PROP_CRLSTATE[i] == CA_DISP_VALID")
cpp_quote("#define CR_PROP_BASECRLPUBLISHSTATUS 30  // Long, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("// Fetch only if Delta CRLs enabled && CR_PROP_CRLSTATE[i] == CA_DISP_VALID")
cpp_quote("#define CR_PROP_DELTACRLPUBLISHSTATUS 31  // Long, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CASIGCERTCRLCHAIN 32  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CAXCHGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CAXCHGCERTCRLCHAIN 33 // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CACERTSTATUSCODE  34  // Long, Indexed")

cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CAFORWARDCROSSCERT 35  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CABACKWARDCROSSCERT 36  // Binary, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CAFORWARDCROSSCERTSTATE 37  // Long, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CABACKWARDCROSSCERTSTATE 38  // Long, Indexed")
cpp_quote("")
cpp_quote("// CR_PROP_CASIGCERTCOUNT Elements:")
cpp_quote("#define CR_PROP_CACERTVERSION       39  // Long, Indexed")
cpp_quote("#define CR_PROP_SANITIZEDCASHORTNAME 40  // String")

//+--------------------------------------------------------------------------
// ICertRequest2::GetFullResponseProperty() PropId

cpp_quote("")
cpp_quote("")
cpp_quote("#define FR_PROP_NONE                    0  // Invalid")
cpp_quote("#define FR_PROP_FULLRESPONSE            1  // Binary")
cpp_quote("#define FR_PROP_STATUSINFOCOUNT         2  // Long")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_BODYPARTSTRING          3  // String, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_STATUS                  4  // Long, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_STATUSSTRING            5  // String, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_OTHERINFOCHOICE         6  // Long, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_FAILINFO                7  // Long, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_PENDINFOTOKEN           8  // Binary, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_PENDINFOTIME            9  // Date, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_ISSUEDCERTIFICATEHASH  10  // Binary, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_ISSUEDCERTIFICATE      11  // Binary, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_ISSUEDCERTIFICATECHAIN 12  // Binary, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_ISSUEDCERTIFICATECRLCHAIN 13  // Binary, Indexed")
cpp_quote("")
cpp_quote("// FR_PROP_STATUSINFOCOUNT Elements:")
cpp_quote("#define FR_PROP_ENCRYPTEDKEYHASH	  14  // Binary, Indexed")
cpp_quote("")
cpp_quote("#define FR_PROP_FULLRESPONSENOPKCS7	  15  // Binary")


//+--------------------------------------------------------------------------
// ICertRequest -- local COM interface, implementation uses DCOM
//+--------------------------------------------------------------------------

[
    object,
    uuid(014e4840-5523-11d0-8812-00a0c903b83c),
    dual,
    helpstring("ICertRequest Interface"),
    pointer_default(unique)
]

interface ICertRequest: IDispatch
{
    HRESULT Submit(
		[in] LONG Flags,
		[in] BSTR const strRequest,
		[in] BSTR const strAttributes,
		[in] BSTR const strConfig,
		[out, retval] LONG *pDisposition);

    HRESULT RetrievePending(
		[in] LONG RequestId,
		[in] BSTR const strConfig,
		[out, retval] LONG *pDisposition);

    HRESULT GetLastStatus(
		[out, retval] LONG *pStatus);

    HRESULT GetRequestId(
		[out, retval] LONG *pRequestId);

    HRESULT GetDispositionMessage(
		[out, retval] BSTR *pstrDispositionMessage);

    HRESULT GetCACertificate(
		[in] LONG fExchangeCertificate,
		[in] BSTR const strConfig,
		[in] LONG Flags,		// CR_OUT_*
		[out, retval] BSTR *pstrCertificate);

    HRESULT GetCertificate(
		[in] LONG Flags,		// CR_OUT_*
		[out, retval] BSTR *pstrCertificate);
};


//+--------------------------------------------------------------------------
// ICertRequest2 -- local COM interface, implementation uses DCOM
//+--------------------------------------------------------------------------

[
    object,
    uuid(a4772988-4a85-4fa9-824e-b5cf5c16405a),
    dual,
    helpstring("ICertRequest2 Interface"),
    pointer_default(unique)
]

interface ICertRequest2: ICertRequest
{
    HRESULT GetIssuedCertificate(
		[in] BSTR const strConfig,
		[in] LONG RequestId,		    // -1: use strSerialNumber
		[in] BSTR const strSerialNumber,    // OPTIONAL
		[out, retval] LONG *pDisposition);

    HRESULT GetErrorMessageText(
		[in] LONG hrMessage,
		[in] LONG Flags,
		[out, retval] BSTR *pstrErrorMessageText);

    HRESULT GetCAProperty(
		[in] BSTR const strConfig,
		[in] LONG PropId,		// CR_PROP_*
		[in] LONG PropIndex,
		[in] LONG PropType,		// PROPTYPE_*
		[in] LONG Flags,		// CR_OUT_*
		[out, retval] VARIANT *pvarPropertyValue);

    HRESULT GetCAPropertyFlags(
		[in] BSTR const strConfig,
		[in] LONG PropId,		// CR_PROP_*
		[out, retval] LONG *pPropFlags); // PROPTYPE_* | PROPFLAGS_*

    HRESULT GetCAPropertyDisplayName(
		[in] BSTR const strConfig,
		[in] LONG PropId,		// CR_PROP_*
		[out, retval] BSTR *pstrDisplayName);

    HRESULT GetFullResponseProperty(
		[in] LONG PropId,		// FR_PROP_*
		[in] LONG PropIndex,
		[in] LONG PropType,		// PROPTYPE_*
		[in] LONG Flags,		// CR_OUT_*
		[out, retval] VARIANT *pvarPropertyValue);
};


//+--------------------------------------------------------------------------
// certcli Type library
//+--------------------------------------------------------------------------

[
    uuid(372fce32-4324-11d0-8810-00a0c903b83c),
    version(1.0),
    helpstring("CertCli 1.0 Type Library")
]

library CERTCLIENTLib
{
    importlib("stdole2.tlb");

    //------------------------------------------------
    // CCertGetConfig
    [
	uuid(c6cc49b0-ce17-11d0-8833-00a0c903b83c),
	helpstring("CertGetConfig Class")
    ]
    coclass CCertGetConfig
    {
	[default] interface ICertGetConfig;
    };

    //------------------------------------------------
    // CCertConfig
    [
	uuid(372fce38-4324-11d0-8810-00a0c903b83c),
	helpstring("CertConfig Class")
    ]
    coclass CCertConfig
    {
	[default] interface ICertConfig2;
    };

    //------------------------------------------------
    // CCertRequest
    [
	uuid(98aff3f0-5524-11d0-8812-00a0c903b83c),
	helpstring("CertRequest Class")
    ]
    coclass CCertRequest
    {
	[default] interface ICertRequest2;
    };

    //------------------------------------------------
    // CCertServerPolicy
    [
	uuid(aa000926-ffbe-11cf-8800-00a0c903b83c),
	helpstring("CertServerPolicy Class")
    ]
    coclass CCertServerPolicy
    {
	[default] interface ICertServerPolicy;
    };

    //------------------------------------------------
    // CCertServerExit
    [
	uuid(4c4a5e40-732c-11d0-8816-00a0c903b83c),
	helpstring("CertServerExit Class")
    ]
    coclass CCertServerExit
    {
	[default] interface ICertServerExit;
    };
};
