## x509 x509 — X509 certificates implementation for Microsoft Cryptography API: Next Generation (CNG). |

## Stability Level

Stable, unless otherwise indicated

## Functions

xmlSecKeyDataId | xmlSecMSCngKeyDataX509GetKlass ()
xmlSecKeyDataId | xmlSecMSCngKeyDataRawX509CertGetKlass ()
xmlSecKeyDataStoreId | xmlSecMSCngX509StoreGetKlass ()
int | xmlSecMSCngKeyDataX509AdoptKeyCert ()
int | xmlSecMSCngKeyDataX509AdoptCert ()
int | xmlSecMSCngX509StoreAdoptCert ()
int | xmlSecMSCngX509StoreAdoptKeyStore ()
int | xmlSecMSCngX509StoreAdoptTrustedStore ()
int | xmlSecMSCngX509StoreAdoptUntrustedStore ()
PCCERT_CONTEXT | xmlSecMSCngX509StoreVerify ()
PCCERT_CONTEXT | xmlSecMSCngX509StoreFindCert ()
PCCERT_CONTEXT | xmlSecMSCngX509FindCertBySubject ()

## Types and Values

#define | xmlSecMSCngKeyDataX509Id
#define | xmlSecMSCngKeyDataRawX509CertId
#define | xmlSecMSCngX509StoreId

## Description

## Functions

### xmlSecMSCngKeyDataX509GetKlass ()

    xmlSecKeyDataId
    xmlSecMSCngKeyDataX509GetKlass (void);

The MSCng X509 key data klass.

#### Returns

the X509 data klass.

### xmlSecMSCngKeyDataRawX509CertGetKlass ()

    xmlSecKeyDataId
    xmlSecMSCngKeyDataRawX509CertGetKlass (void);

The raw X509 certificates key data klass.

#### Returns

raw X509 certificates key data klass.

### xmlSecMSCngX509StoreGetKlass ()

    xmlSecKeyDataStoreId
    xmlSecMSCngX509StoreGetKlass (void);

The MSCng X509 certificates key data store klass.

#### Returns

pointer to MSCng X509 certificates key data store klass.

### xmlSecMSCngKeyDataX509AdoptKeyCert ()

    int
    xmlSecMSCngKeyDataX509AdoptKeyCert (xmlSecKeyDataPtr data,
                                        PCCERT_CONTEXT cert);

### xmlSecMSCngKeyDataX509AdoptCert ()

    int
    xmlSecMSCngKeyDataX509AdoptCert (xmlSecKeyDataPtr data,
                                     PCCERT_CONTEXT cert);

### xmlSecMSCngX509StoreAdoptCert ()

    int
    xmlSecMSCngX509StoreAdoptCert (xmlSecKeyDataStorePtr store,
                                   PCCERT_CONTEXT cert,
                                   xmlSecKeyDataType type);

Adds trusted (root) or untrusted certificate to the store.

#### Parameters

store | the pointer to X509 key data store klass. |
cert | the pointer to PCCERT_CONTEXT X509 certificate. |
type | the certificate type (trusted/untrusted). |

#### Returns

0 on success or a negative value if an error occurs.

### xmlSecMSCngX509StoreAdoptKeyStore ()

    int
    xmlSecMSCngX509StoreAdoptKeyStore (xmlSecKeyDataStorePtr store,
                                       HCERTSTORE keyStore);

Adds `keyStore` to the list of key stores.

#### Parameters

store | the pointer to X509 key data store klass. |
keyStore | the pointer to keys store. |

#### Returns

0 on success or a negative value if an error occurs.

### xmlSecMSCngX509StoreAdoptTrustedStore ()

    int
    xmlSecMSCngX509StoreAdoptTrustedStore (xmlSecKeyDataStorePtr store,
                                           HCERTSTORE trustedStore);

Adds `trustedStore` to the list of trusted certs stores.

#### Parameters

store | the pointer to X509 key data store klass. |
trustedStore | the pointer to certs store. |

#### Returns

0 on success or a negative value if an error occurs.

### xmlSecMSCngX509StoreAdoptUntrustedStore ()

    int
    xmlSecMSCngX509StoreAdoptUntrustedStore
                                   (xmlSecKeyDataStorePtr store,
                                    HCERTSTORE untrustedStore);

Adds `trustedStore` to the list of untrusted certs stores.

#### Parameters

store | the pointer to X509 key data store klass. |
untrustedStore | the pointer to certs store. |

#### Returns

0 on success or a negative value if an error occurs.

### xmlSecMSCngX509StoreVerify ()

    PCCERT_CONTEXT
    xmlSecMSCngX509StoreVerify (xmlSecKeyDataStorePtr store,
                                HCERTSTORE certs,
                                xmlSecKeyInfoCtx *keyInfoCtx);

Verifies `certs` list.

#### Parameters

store | the pointer to X509 certificate context store klass. |
certs | the untrusted certificates stack. |
keyInfoCtx | the pointer to <dsig:KeyInfo/> element processing context. |

#### Returns

pointer to the first verified certificate from `certs` .

### xmlSecMSCngX509StoreFindCert ()

    PCCERT_CONTEXT
    xmlSecMSCngX509StoreFindCert (xmlSecKeyDataStorePtr store,
                                  xmlChar *subjectName,
                                  xmlChar *issuerName,
                                  xmlChar *issuerSerial,
                                  xmlChar *ski,
                                  xmlSecKeyInfoCtx *keyInfoCtx);

Searches `store` for a certificate that matches given criteria.

#### Parameters

store | the pointer to X509 key data store klass. |
subjectName | the desired certificate name. |
issuerName | the desired certificate issuer name. |
issuerSerial | the desired certificate issuer serial number. |
ski | the desired certificate SKI. |
keyInfoCtx | the pointer to <dsig:KeyInfo/> element processing context. |

#### Returns

pointer to found certificate or NULL if certificate is not found or an error occurs.

### xmlSecMSCngX509FindCertBySubject ()

    PCCERT_CONTEXT
    xmlSecMSCngX509FindCertBySubject (HCERTSTORE store,
                                      LPTSTR wcSubject,
                                      DWORD dwCertEncodingType);

Searches for a cert with given `subject` in the `store`

#### Parameters

store | the pointer to certs store |
wcSubject | the cert subject (Unicode) |
dwCertEncodingType | the cert encoding type |

#### Returns

cert handle on success or NULL otherwise

## Types and Values

### xmlSecMSCngKeyDataX509Id

    #define             xmlSecMSCngKeyDataX509Id

The MSCng X509 data klass.

### xmlSecMSCngKeyDataRawX509CertId

    #define             xmlSecMSCngKeyDataRawX509CertId

The MSCng raw X509 certificate klass.

### xmlSecMSCngX509StoreId

    #define             xmlSecMSCngX509StoreId

The MSCng X509 store klass.