IX509PrivateKey::ProviderType property

The ProviderType property specifies or retrieves the type of cryptographic provider associated with the private key. This property is web enabled for both input and output.

This property is read/write.


HRESULT put_ProviderType(
  [in]  X509ProviderType Value

HRESULT get_ProviderType(
  [out] X509ProviderType *pValue

Property value

An X509ProviderType enumeration value that specifies the provider type.

Error codes

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. Possible values include, but are not limited to, those in the following table. For a list of common error codes, see Common HRESULT Values.


The property value could not be found.


The key is open, and the property value cannot be set.


You can use this property to force the use of the default provider for a given provider type. For example, to use the PROV_RSA_SCHANNEL provider, set this property to the XCN_PROV_RSA_SCHANNELX509ProviderType enumeration value and do not specify a value for the ProviderName property.

Setting this property automatically sets the following properties to be consistent with the specified ProviderType value:

These properties are set in the following manner:

  • If the ProviderType is set to XCN_PROV_NONE:
    • The LegacyCsp property is set to VARIANT_FALSE.
    • The KeySpec property is set to XCN_AT_NONE.
  • If the ProviderType is not set to XCN_PROV_NONE:
    • The LegacyCsp property is set to VARIANT_TRUE.
    • The KeySpec property is set to XCN_AT_SIGNATURE if the current value is XCN_AT_NONE.

Because a previously specified ProviderName is not affected by setting the ProviderType property, setting a ProviderType that is inconsistent with the ProviderName property will result in undefined behavior, likely a failure when creating or opening a private key. We recommend that you set the ProviderType property only when attempting to force the use of the default provider for the specified type as discussed above.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]





See also




Community Additions