XML Security Library Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# x509.h

## Name

x509.h -- The X509 certificates functions.

## Synopsis

    xmlSecX509DataPtr xmlSecX509DataCreate      (void);
    void        xmlSecX509DataDestroy           (xmlSecX509DataPtr x509Data);
    size_t      xmlSecX509DataGetCertsNumber    (xmlSecX509DataPtr x509Data);
    size_t      xmlSecX509DataGetCrlsNumber     (xmlSecX509DataPtr x509Data);
    int         xmlSecX509DataReadDerCert       (xmlSecX509DataPtr x509Data,
                                                 xmlChar *buf,
                                                 size_t size,
                                                 int base64);
    xmlChar*    xmlSecX509DataWriteDerCert      (xmlSecX509DataPtr x509Data,
                                                 int pos);
    int         xmlSecX509DataReadDerCrl        (xmlSecX509DataPtr x509Data,
                                                 xmlChar *buf,
                                                 size_t size,
                                                 int base64);
    xmlChar*    xmlSecX509DataWriteDerCrl       (xmlSecX509DataPtr x509Data,
                                                 int pos);
    int         xmlSecX509DataReadPemCert       (xmlSecX509DataPtr x509Data,
                                                 const char *filename);
    xmlSecX509DataPtr xmlSecX509DataDup         (xmlSecX509DataPtr x509Data);
    xmlSecKeyPtr xmlSecX509DataCreateKey        (xmlSecX509DataPtr x509Data);
    void        xmlSecX509DataDebugDump         (xmlSecX509DataPtr x509Data,
                                                 FILE *output);
    xmlSecX509StorePtr xmlSecX509StoreCreate    (void);
    void        xmlSecX509StoreDestroy          (xmlSecX509StorePtr store);
    xmlSecX509DataPtr xmlSecX509StoreFind       (xmlSecX509StorePtr store,
                                                 xmlChar *subjectName,
                                                 xmlChar *issuerName,
                                                 xmlChar *issuerSerial,
                                                 xmlChar *ski,
                                                 xmlSecX509DataPtr x509Data);
    int         xmlSecX509StoreVerify           (xmlSecX509StorePtr store,
                                                 xmlSecX509DataPtr x509Data);
    int         xmlSecX509StoreLoadPemCert      (xmlSecX509StorePtr store,
                                                 const char *filename,
                                                 int trusted);
    int         xmlSecX509StoreAddCertsDir      (xmlSecX509StorePtr store,
                                                 const char *path);
    xmlSecKeyPtr xmlSecPKCS12ReadKey            (const char *filename,
                                                 const char *pwd);

## Description

## Details

### xmlSecX509DataCreate ()

    xmlSecX509DataPtr xmlSecX509DataCreate      (void);

Creates new x509 data.

Returns : | the pointer to newly created xmlSecX509Data structure or NULL if an error occurs.

### xmlSecX509DataDestroy ()

    void        xmlSecX509DataDestroy           (xmlSecX509DataPtr x509Data);

Destroys x509 data.

`x509Data` : | the pointer to xmlSecX509Data structure.

### xmlSecX509DataGetCertsNumber ()

    size_t      xmlSecX509DataGetCertsNumber    (xmlSecX509DataPtr x509Data);

Gets the number of certs in `x509Data`.

`x509Data` : | the pointer to xmlSecX509Data structure.
Returns : | the number of certs in `x509Data`.

### xmlSecX509DataGetCrlsNumber ()

    size_t      xmlSecX509DataGetCrlsNumber     (xmlSecX509DataPtr x509Data);

Gets the number of crls in `x509Data`.

`x509Data` : | the pointer to xmlSecX509Data structure.
Returns : | the number of crls in `x509Data`.

### xmlSecX509DataReadDerCert ()

    int         xmlSecX509DataReadDerCert       (xmlSecX509DataPtr x509Data,
                                                 xmlChar *buf,
                                                 size_t size,
                                                 int base64);

Reads certificates the from a DER binary data in `buf`.

`x509Data` : | the pointer to xmlSecX509Data structure.
`buf` : | the pointer to binary data.
`size` : | the size of binary data.
`base64` : | the flag that indicate whether the `buf` is base64 encoded or not.
Returns : | 0 on success or a negative value otherwise.

### xmlSecX509DataWriteDerCert ()

    xmlChar*    xmlSecX509DataWriteDerCert      (xmlSecX509DataPtr x509Data,
                                                 int pos);

Writes `pos` certificate from `x509Data` into allocated buffer in DER + base64 encode format. The caller is responsible for freeing the returned buffer using xmlFree() function.

`x509Data` : | the pointer to xmlSecX509Data structure.
`pos` : | the cert number.
Returns : | the pointer to allocated result buffer or NULL if an error occurs.

### xmlSecX509DataReadDerCrl ()

    int         xmlSecX509DataReadDerCrl        (xmlSecX509DataPtr x509Data,
                                                 xmlChar *buf,
                                                 size_t size,
                                                 int base64);

Reads crls the from a DER binary data in `buf`.

`x509Data` : | the pointer to xmlSecX509Data structure.
`buf` : | the pointer to binary data.
`size` : | the size of binary data.
`base64` : | the flag that indicate whether the `buf` is base64 encoded or not.
Returns : | 0 on success or a negative value otherwise.

### xmlSecX509DataWriteDerCrl ()

    xmlChar*    xmlSecX509DataWriteDerCrl       (xmlSecX509DataPtr x509Data,
                                                 int pos);

Writes `pos` crl from `x509Data` into allocated buffer in DER + base64 encode format. The caller is responsible for freeing the returned buffer using xmlFree() function.

`x509Data` : | the pointer to xmlSecX509Data structure.
`pos` : | the cert number.
Returns : | the pointer to allocated result buffer or NULL if an error occurs.

### xmlSecX509DataReadPemCert ()

    int         xmlSecX509DataReadPemCert       (xmlSecX509DataPtr x509Data,
                                                 const char *filename);

Reads cert from PEM file `filename` into `x509Data`.

`x509Data` : | the pointer to xmlSecX509Data structure.
`filename` : | the PEM file name.
Returns : | 0 on success or a negative value otherwise.

### xmlSecX509DataDup ()

    xmlSecX509DataPtr xmlSecX509DataDup         (xmlSecX509DataPtr x509Data);

Duplicates the `x509Data` structure.

`x509Data` : | the pointer to xmlSecX509Data structure.
Returns : | the pointer to newly created xmlSecX509Data structure or NULL if an error occurs.

### xmlSecX509DataCreateKey ()

    xmlSecKeyPtr xmlSecX509DataCreateKey        (xmlSecX509DataPtr x509Data);

Creates the key from `x509Data`.

`x509Data` : | the pointer to xmlSecX509Data structure.
Returns : | the pointer to newly allocated key or NULL if an error occurs.

### xmlSecX509DataDebugDump ()

    void        xmlSecX509DataDebugDump         (xmlSecX509DataPtr x509Data,
                                                 FILE *output);

Prints the information about `x509Data` to `output`.

`x509Data` : | the pointer to xmlSecX509Data structure.
`output` : | the pointer to FILE structure.

### xmlSecX509StoreCreate ()

    xmlSecX509StorePtr xmlSecX509StoreCreate    (void);

Creates new x509 store.

Returns : | the pointer to newly allocated xmlSecX509Store structure.

### xmlSecX509StoreDestroy ()

    void        xmlSecX509StoreDestroy          (xmlSecX509StorePtr store);

Destroys the xmlSecX509Store structure.

`store` : | the pointer to xmlSecX509Store structure.

### xmlSecX509StoreFind ()

    xmlSecX509DataPtr xmlSecX509StoreFind       (xmlSecX509StorePtr store,
                                                 xmlChar *subjectName,
                                                 xmlChar *issuerName,
                                                 xmlChar *issuerSerial,
                                                 xmlChar *ski,
                                                 xmlSecX509DataPtr x509Data);

Searches for matching certificate in the keys manager.

`store` : | the pointer to xmlSecX509Store structure.
`subjectName` : | the subject name string.
`issuerName` : | the issuer name string.
`issuerSerial` : | the issuer serial.
`ski` : | the SKI string.
`x509Data` : | the current X509 certs data (may be NULL).
Returns : | the pointer to certificate that matches given criteria or NULL if an error occurs or certificate not found.

### xmlSecX509StoreVerify ()

    int         xmlSecX509StoreVerify           (xmlSecX509StorePtr store,
                                                 xmlSecX509DataPtr x509Data);

Verifies the cert(s) from `x509Data` against `store`.

`store` : | the pointer to xmlSecX509Store structure.
`x509Data` : | the pointer to xmlSecX509Data structure.
Returns : | 1 if verification succeeded, 0 if not and a negative value if a processing error occurs.

### xmlSecX509StoreLoadPemCert ()

    int         xmlSecX509StoreLoadPemCert      (xmlSecX509StorePtr store,
                                                 const char *filename,
                                                 int trusted);

Reads cert from PEM `filename` and adds to the list of trusted or known untrusted certs in `store`.

`store` : | the pointer to xmlSecX509Store structure.
`filename` : | the PEM file.
`trusted` : | the flag that indicates is the certificate in `filename` trusted or not.
Returns : | 0 on success or a negative value otherwise.

### xmlSecX509StoreAddCertsDir ()

    int         xmlSecX509StoreAddCertsDir      (xmlSecX509StorePtr store,
                                                 const char *path);

Adds all certs in the `path` to the list of trusted certs in `store`.

`store` : | the pointer to xmlSecX509Store structure.
`path` : | the path to the certs dir.
Returns : | 0 on success or a negative value otherwise.

### xmlSecPKCS12ReadKey ()

    xmlSecKeyPtr xmlSecPKCS12ReadKey            (const char *filename,
                                                 const char *pwd);

Reads the key from pkcs12 file `filename`.

`filename` : | the pkcs12 file name.
`pwd` : | the password for the pkcs12 file.
Returns : | the pointer to newly allocated key or NULL if an error occurs.

<<< Previous Page | Home | Up | Next Page >>>
version.h | XML Security Library Internal Functions Reference