CSR¶
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
FfiResult_FfiCsrProperties fatoora_csr_properties_new(
const char* common_name,
const char* serial_number,
const char* organization_identifier,
const char* organization_unit_name,
const char* organization_name,
const char* country_name,
const char* invoice_type,
const char* location_address,
const char* industry_business_category
);
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
FfiResult_FfiCsrProperties fatoora_csr_properties_from_str(const char* properties);
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
FfiResult_FfiCsrProperties fatoora_csr_properties_parse_csr_config(const char* properties);
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
FfiResult_FfiCsrProperties fatoora_csr_properties_parse_csr_config_file(const char* path);
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
FfiResult_FfiCsr fatoora_csr_build(FfiCsrProperties* props, FfiSigningKey* key, FfiEnvironment env);
SigningKey¶
generate¶
Generate key
Generate a new signing key.
SigningKey::generate() -> SigningKey
SigningKey.generate() -> SigningKey
FfiResult_FfiSigningKey fatoora_signing_key_generate(void);
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
FfiResult_FfiSigningKey fatoora_signing_key_from_pem(const char* pem);
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
FfiResult_FfiSigningKey fatoora_signing_key_from_der(const uint8_t* der, uintptr_t len);
to_pem¶
Serialize key to PEM
Serialize the key to PEM format.
SigningKey::to_pem(&self) -> Result<String, CsrError>
SigningKey.to_pem() -> str
FfiResult_FfiString fatoora_signing_key_to_pem(FfiSigningKey* key);
to_der¶
Serialize key to DER
Serialize the key to DER format.
SigningKey::to_der(&self) -> Result<Vec<u8>, CsrError>
SigningKey.to_der() -> bytes
FfiResult_FfiBytes fatoora_signing_key_to_der(FfiSigningKey* key);
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
FfiResult_FfiCsr fatoora_csr_from_der(const uint8_t* der, uintptr_t len);
to_pem¶
Serialize CSR to PEM
Csr::to_pem(&self) -> Result<String, CsrError>
Csr.to_pem() -> str
FfiResult_FfiString fatoora_csr_to_pem(FfiCsr* csr);
to_der¶
Serialize CSR to DER
Csr::to_der(&self) -> Result<Vec<u8>, CsrError>
Csr.to_der() -> bytes
FfiResult_FfiBytes fatoora_csr_to_der(FfiCsr* csr);
to_base64¶
Serialize CSR DER to Base64
Csr::to_base64(&self) -> Result<String, CsrError>
Csr.to_base64() -> str
FfiResult_FfiString fatoora_csr_to_base64(FfiCsr* csr);
to_pem_base64¶
Serialize PEM CSR to Base64
Csr::to_pem_base64(&self) -> Result<String, CsrError>
Csr.to_pem_base64() -> str
FfiResult_FfiString fatoora_csr_to_pem_base64(FfiCsr* csr);
subject_string¶
Get CSR subject string
Csr::subject_string(&self) -> String
Csr.subject_string() -> str
FfiResult_FfiString fatoora_csr_subject_string(FfiCsr* csr);
extension_values_der¶
Get extension DER values
Csr::extension_values_der(&self) -> Vec<Vec<u8>>
Csr.extension_values_der() -> list[bytes]
FfiResult_FfiBytesList fatoora_csr_extension_values_der(FfiCsr* csr);
Errors¶
Errors
CsrErrorcovers 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