Skip to content

CSR

C signatures use the C API. See C and C++ bindings for ownership and build instructions. The declarations below come from the generated headers. C++ exposes the same types in namespace fatoora through fatoora/Type.hpp headers.

CSR parsing and generation helpers shared by Rust, FFI, and Python.

CsrProperties

new

Create CSR properties

Construct CsrProperties from explicit fields.

CsrProperties::new(
    common_name: impl Into<String>,
    serial_number: impl Into<String>,
    organization_identifier: impl Into<String>,
    organization_unit_name: impl Into<String>,
    organization_name: impl Into<String>,
    country_name: impl Into<String>,
    invoice_type: impl Into<String>,
    location_address: impl Into<String>,
    industry_business_category: impl Into<String>,
) -> Result<CsrProperties, CsrError>
CsrProperties.new(
    common_name: str,
    serial_number: str,
    organization_identifier: str,
    organization_unit_name: str,
    organization_name: str,
    country_name: str,
    invoice_type: str,
    location_address: str,
    industry_business_category: str,
) -> CsrProperties
#include "fatoora.h"

FatooraStatus fatoora_csr_properties_new(const FatooraCsrOptions *options,
    FatooraCsrProperties **out,
    FatooraError **error);

from_properties_str

Parse CSR properties string

Parse properties text into CsrProperties.

CsrProperties::from_properties_str(properties: &str) -> Result<CsrProperties, CsrError>
CsrProperties.from_properties_str(properties: str) -> CsrProperties
#include "fatoora.h"

FatooraStatus fatoora_csr_properties_from_properties_str(const char *properties,
    FatooraCsrProperties **out,
    FatooraError **error);

parse_csr_config

Parse CSR config

Parse properties text using the config parser alias.

CsrProperties::parse_csr_config(properties: &str) -> Result<CsrProperties, CsrError>
CsrProperties.parse_csr_config(properties: str) -> CsrProperties
#include "fatoora.h"

FatooraStatus fatoora_csr_properties_from_properties_str(const char *properties,
    FatooraCsrProperties **out,
    FatooraError **error);

parse_csr_config_file

Parse CSR config file

Parse properties from a file path.

CsrProperties::parse_csr_config_file(path: impl AsRef<Path>) -> Result<CsrProperties, CsrError>
CsrProperties.parse_csr_config_file(path: str) -> CsrProperties
#include "fatoora.h"

FatooraStatus fatoora_csr_properties_parse_csr_config_file(const char *path,
    FatooraCsrProperties **out,
    FatooraError **error);

build

Build CSR

Build a CSR from properties and signing key.

CsrProperties::build(&self, signer: &SigningKey, env: EnvironmentType) -> Result<Csr, CsrError>
CsrProperties.build(key: SigningKey, env: Environment) -> Csr
#include "fatoora.h"

FatooraStatus fatoora_csr_properties_build(const FatooraCsrProperties *self,
    const FatooraSigningKey *key,
    int32_t env,
    FatooraCsr **out,
    FatooraError **error);

SigningKey

generate

Generate key

Generate a new signing key.

SigningKey::generate() -> SigningKey
SigningKey.generate() -> SigningKey
#include "fatoora.h"

FatooraStatus fatoora_signing_key_generate(FatooraSigningKey **out,
    FatooraError **error);

from_pem

Load key from PEM

Parse PKCS#8 key material in PEM format.

SigningKey::from_pem(pem: &str) -> Result<SigningKey, CsrError>
SigningKey.from_pem(pem: str) -> SigningKey
#include "fatoora.h"

FatooraStatus fatoora_signing_key_from_pem(const char *pem,
    FatooraSigningKey **out,
    FatooraError **error);

from_der

Load key from DER

Parse PKCS#8 key material in DER format.

SigningKey::from_der(der: &[u8]) -> Result<SigningKey, CsrError>
SigningKey.from_der(der: bytes) -> SigningKey
#include "fatoora.h"

FatooraStatus fatoora_signing_key_from_der(const uint8_t *der,
    size_t der_len,
    FatooraSigningKey **out,
    FatooraError **error);

to_pem

Serialize key to PEM

Serialize the key to PEM format.

SigningKey::to_pem(&self) -> Result<String, CsrError>
SigningKey.to_pem() -> str
#include "fatoora.h"

FatooraStatus fatoora_signing_key_to_pem(const FatooraSigningKey *self,
    char **out,
    FatooraError **error);

to_der

Serialize key to DER

Serialize the key to DER format.

SigningKey::to_der(&self) -> Result<Vec<u8>, CsrError>
SigningKey.to_der() -> bytes
#include "fatoora.h"

FatooraStatus fatoora_signing_key_to_der(const FatooraSigningKey *self,
    FatooraBytes **out,
    FatooraError **error);

Csr

from_der

Load CSR from DER

Parse CSR bytes in DER format.

Csr::from_der(der: &[u8]) -> Result<Csr, CsrError>
Csr.from_der(der: bytes) -> Csr
#include "fatoora.h"

FatooraStatus fatoora_csr_from_der(const uint8_t *der,
    size_t der_len,
    FatooraCsr **out,
    FatooraError **error);

to_pem

Serialize CSR to PEM
Csr::to_pem(&self) -> Result<String, CsrError>
Csr.to_pem() -> str
#include "fatoora.h"

FatooraStatus fatoora_csr_to_pem(const FatooraCsr *self,
    char **out,
    FatooraError **error);

to_der

Serialize CSR to DER
Csr::to_der(&self) -> Result<Vec<u8>, CsrError>
Csr.to_der() -> bytes
#include "fatoora.h"

FatooraStatus fatoora_csr_to_der(const FatooraCsr *self,
    FatooraBytes **out,
    FatooraError **error);

to_base64

Serialize CSR DER to Base64
Csr::to_base64(&self) -> Result<String, CsrError>
Csr.to_base64() -> str
#include "fatoora.h"

FatooraStatus fatoora_csr_to_base64(const FatooraCsr *self,
    char **out,
    FatooraError **error);

to_pem_base64

Serialize PEM CSR to Base64
Csr::to_pem_base64(&self) -> Result<String, CsrError>
Csr.to_pem_base64() -> str
#include "fatoora.h"

FatooraStatus fatoora_csr_to_pem_base64(const FatooraCsr *self,
    char **out,
    FatooraError **error);

subject_string

Get CSR subject string
Csr::subject_string(&self) -> String
Csr.subject_string() -> str
#include "fatoora.h"

FatooraStatus fatoora_csr_subject_string(const FatooraCsr *self,
    char **out,
    FatooraError **error);

extension_values_der

Get extension DER values
Csr::extension_values_der(&self) -> Vec<Vec<u8>>
Csr.extension_values_der() -> list[bytes]
#include "fatoora.h"

FatooraStatus fatoora_csr_extension_values_der(const FatooraCsr *self,
    FatooraBytesList **out,
    FatooraError **error);

Errors

Errors

  • CsrError covers parsing, missing fields, subject/SAN build failures, encoding issues, and IO.

Notes

Notes

  • The template name extension is selected from EnvironmentType.
  • Csr.to_pem_base64() is the value expected by the ZATCA compliance endpoint.

See also: CSR Guide