# MsCrypto X.509 Support

**API Group:** `xmlsec_mscrypto_x509`

X.509 certificate handling for the MsCrypto back-end.

X509 certificates verification support functions for MSCrypto.

X509 certificates implementation for Microsoft Crypto API. X509 certificates implementation for Microsoft Crypto API.

## Macros

### `xmlSecMSCryptoKeyDataX509Id`

*Defined as:* `xmlSecMSCryptoKeyDataX509GetKlass()`

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L28)

The MSCrypto X509 data klass.

---

### `xmlSecMSCryptoKeyDataRawX509CertId`

*Defined as:* `xmlSecMSCryptoKeyDataRawX509CertGetKlass()`

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L51)

The MSCrypto raw X509 certificate klass.

---

### `xmlSecMSCryptoX509StoreId`

*Defined as:* `xmlSecMSCryptoX509StoreGetKlass()`

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L58)

The MSCrypto X509 store klass.

---

## Functions

### `xmlSecMSCryptoKeyDataX509GetKlass`

```c
xmlSecKeyDataId xmlSecMSCryptoKeyDataX509GetKlass(void);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L30)

The MSCrypto X509 key data klass.

The MSCrypto X509 key data klass ([http://www.w3.org/TR/xmldsig-core/#sec-X509Data](http://www.w3.org/TR/xmldsig-core/#sec-X509Data)). 

**Returns:** the X509 data klass.

---

### `xmlSecMSCryptoKeyDataX509GetKeyCert`

```c
void * xmlSecMSCryptoKeyDataX509GetKeyCert(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L32)

Gets the certificate from which the key was extracted.

**Parameters:**

- `data` — the pointer to X509 key data.


**Returns:** the key's certificate or NULL if key data was not used for key extraction or an error occurs.

---

### `xmlSecMSCryptoKeyDataX509AdoptKeyCert`

```c
int xmlSecMSCryptoKeyDataX509AdoptKeyCert(xmlSecKeyDataPtr data, void *cert);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L33)

Sets the key's certificate in `data`.

**Parameters:**

- `data` — the pointer to X509 key data.
- `cert` — the pointer to MSCRYPTO X509 certificate.


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

---

### `xmlSecMSCryptoKeyDataX509AdoptCert`

```c
int xmlSecMSCryptoKeyDataX509AdoptCert(xmlSecKeyDataPtr data, void *cert);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L35)

Adds certificate to the X509 key data.

**Parameters:**

- `data` — the pointer to X509 key data.
- `cert` — the pointer to MSCRYPTO X509 certificate.


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

---

### `xmlSecMSCryptoKeyDataX509GetCert`

```c
void * xmlSecMSCryptoKeyDataX509GetCert(xmlSecKeyDataPtr data, xmlSecSize pos);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L37)

Gets a certificate from X509 key data.

**Parameters:**

- `data` — the pointer to X509 key data.
- `pos` — the desired certificate position.


**Returns:** the pointer to certificate or NULL if `pos` is larger than the number of certificates in `data` or an error occurs.

---

### `xmlSecMSCryptoKeyDataX509GetCertsSize`

```c
xmlSecSize xmlSecMSCryptoKeyDataX509GetCertsSize(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L39)

Gets the number of certificates in `data`.

**Parameters:**

- `data` — the pointer to X509 key data.


**Returns:** te number of certificates in `data`.

---

### `xmlSecMSCryptoKeyDataX509AdoptCrl`

```c
int xmlSecMSCryptoKeyDataX509AdoptCrl(xmlSecKeyDataPtr data, PCCRL_CONTEXT crl);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L41)

Adds CRL to the X509 key data.

**Parameters:**

- `data` — the pointer to X509 key data.
- `crl` — the pointer to MSCrypto X509 CRL.


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

---

### `xmlSecMSCryptoKeyDataX509GetCrl`

```c
PCCRL_CONTEXT xmlSecMSCryptoKeyDataX509GetCrl(xmlSecKeyDataPtr data, xmlSecSize pos);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L43)

Gets a CRL from X509 key data.

**Parameters:**

- `data` — the pointer to X509 key data.
- `pos` — the desired CRL position.


**Returns:** the pointer to CRL or NULL if `pos` is larger than the number of CRLs in `data` or an error occurs.

---

### `xmlSecMSCryptoKeyDataX509GetCrlsSize`

```c
xmlSecSize xmlSecMSCryptoKeyDataX509GetCrlsSize(xmlSecKeyDataPtr data);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L45)

Gets the number of CRLs in `data`.

**Parameters:**

- `data` — the pointer to X509 key data.


**Returns:** te number of CRLs in `data`.

---

### `xmlSecMSCryptoKeyDataRawX509CertGetKlass`

```c
xmlSecKeyDataId xmlSecMSCryptoKeyDataRawX509CertGetKlass(void);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L53)

The raw X509 certificates key data klass.

**Returns:** raw X509 certificates key data klass.

---

### `xmlSecMSCryptoX509StoreGetKlass`

```c
xmlSecKeyDataStoreId xmlSecMSCryptoX509StoreGetKlass(void);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L60)

The MSCrypto X509 certificates store klass.

The MSCrypto X509 certificates key data store klass. 

**Returns:** pointer to MSCrypto X509 certificates key data store klass.

---

### `xmlSecMSCryptoX509StoreAdoptCert`

```c
int xmlSecMSCryptoX509StoreAdoptCert(xmlSecKeyDataStorePtr store, void *cert, xmlSecKeyDataType type);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L62)

Adds trusted or untrusted certificate to the store.

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

**Parameters:**

- `store` — the pointer to X509 key data store klass.
- `pCert` — 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.

---

### `xmlSecMSCryptoX509StoreAdoptKeyStore`

```c
int xmlSecMSCryptoX509StoreAdoptKeyStore(xmlSecKeyDataStorePtr store, void *keyStore);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L66)

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.

---

### `xmlSecMSCryptoX509StoreAdoptTrustedStore`

```c
int xmlSecMSCryptoX509StoreAdoptTrustedStore(xmlSecKeyDataStorePtr store, void *trustedStore);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L69)

Adds `trustedStore` to the trusted certs list.

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.

---

### `xmlSecMSCryptoX509StoreAdoptUntrustedStore`

```c
int xmlSecMSCryptoX509StoreAdoptUntrustedStore(xmlSecKeyDataStorePtr store, void *untrustedStore);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L72)

Adds `trustedStore` to the untrusted certs list.

Adds `trustedStore` to the list of un-trusted 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.

---

### `xmlSecMSCryptoX509StoreEnableSystemTrustedCerts`

```c
void xmlSecMSCryptoX509StoreEnableSystemTrustedCerts(xmlSecKeyDataStorePtr store, int val);
```

*Source:* [include/xmlsec/mscrypto/x509.h](https://github.com/lsh123/xmlsec/blob/1.3.12/include/xmlsec/mscrypto/x509.h#L75)

Enables/disables the system trusted certs.

**Parameters:**

- `store` — the pointer to X509 key data store klass.
- `val` — the enable/disable flag

---
