Skip to content

Error Codes

Every expected failure in micro509 carries a machine-readable code. Result-returning APIs put it on result.error.code (or result.code on flattened failures); builder APIs that take developer-supplied config throw a coded error that isResultError detects and error.code discriminates.

This page lists every public error-code union and its members, grouped by the entrypoint that owns it. A repo test extracts these unions from the type declarations and fails when this page and the exported types disagree, in either direction.

Stability

Unions may gain members in minor releases; treat them as non-exhaustive and keep a default branch. Renaming or removing a code only happens in a major release.

micro509/x509

ParseCertificateErrorCode

CodeMeaning
malformedInput is not a valid DER or PEM X.509 certificate

ParseCertificateSigningRequestErrorCode

CodeMeaning
malformedInput is not a valid DER or PEM PKCS#10 request

MatchCertificatePrivateKeyErrorCode

CodeMeaning
key_mismatchRight algorithm, different key
key_type_mismatchPrivate key algorithm differs from the SPKI's
malformed_certificateCertificate source failed to parse
unsupported_private_keyKey type has no supported SPKI derivation

CreateCertificateErrorCode

CodeMeaning
issuer_distinguished_name_emptyRFC 5280 §4.1.2.4 requires a non-empty issuer DN
serial_number_not_positiveSerial must be a positive integer (RFC 5280 §4.1.2.2)
serial_number_too_longSerial DER INTEGER exceeds 20 octets (RFC 5280 §4.1.2.2)
validity_not_after_before_not_beforeValidity window ends before it starts

NameEncoderErrorCode

CodeMeaning
invalid_country_codeCountry attribute is not exactly two letters
name_attribute_emptyAttribute value is empty (RFC 5280 A.1 SIZE (1..))
name_attribute_too_longAttribute value exceeds its RFC 5280 A.1 upper bound
relative_distinguished_name_emptyRDN carries no attributes
unsupported_name_fieldAttribute key is not an encodable name field

ExtensionEncoderErrorCode

CodeMeaning
authority_info_access_emptyAIA input has no access descriptions
authority_info_access_ocsp_not_uriAn OCSP access method requires a URI location
certificate_policies_emptycertificatePolicies lists no policies
crl_distribution_points_emptycRLDistributionPoints lists no points
directory_name_not_sequencedirectoryName payload is not a DER SEQUENCE
display_text_out_of_rangeUser-notice DisplayText length outside RFC 5280 bounds
distribution_point_crl_issuer_emptycRLIssuer present but holds no name
distribution_point_crl_issuer_not_directory_namecRLIssuer entries must be directoryNames (RFC 5280 §4.2.1.13)
distribution_point_emptyDistribution point carries no field at all
distribution_point_full_name_emptyfullName present but holds no GeneralName
distribution_point_relative_name_multiple_crl_issuersnameRelativeToCRLIssuer permits at most one cRLIssuer
duplicate_extension_oidSame extension OID supplied twice
duplicate_policy_oidSame policy OID listed twice
edwards_key_usage_forbids_agreement_bitEd25519/Ed448 keyUsage asserts an agreement or cipher bit
edwards_key_usage_forbids_key_cert_signEnd-entity Edwards certificate asserts keyCertSign/cRLSign
edwards_key_usage_requires_key_cert_signEdwards CA keyUsage missing keyCertSign
edwards_key_usage_requires_signing_bitEdwards keyUsage missing a signing bit (RFC 9295 §3)
empty_general_name_valuedNSName/rfc822Name/URI/SRV value is empty
empty_subject_requires_subject_alt_nameEmpty subject DN without a critical, non-empty SAN
extended_key_usage_emptyEKU list is empty
extension_must_be_criticalRFC 5280 fixes this extension as critical
extension_must_be_non_criticalRFC 5280 fixes this extension as non-critical
extension_not_supported_in_contextExtension not allowed in this certificate/CSR context
invalid_general_name_tagGeneralName tag outside the nine RFC 5280 §4.2.1.6 alternatives
invalid_ia5_stringNon-ASCII input for an IA5String value
invalid_ip_name_constraintIP constraint bytes are not address+mask of one family
invalid_oidString is not an encodable OID within X.660 arc bounds
key_usage_emptykeyUsage asserts no bits
malformed_known_extension_valuecustomExtensions payload with a known OID fails to decode as it
montgomery_key_usage_forbids_both_cipher_bitsX25519/X448 asserts both encipherOnly and decipherOnly
montgomery_key_usage_forbids_signature_bitX25519/X448 asserts a signature bit (RFC 8410 §12)
montgomery_key_usage_requires_key_agreementX25519/X448 keyUsage missing keyAgreement (RFC 9295 §3)
name_constraints_emptynameConstraints has neither permitted nor excluded subtrees
path_length_requires_capathLength on a non-CA basicConstraints
path_length_requires_key_cert_signpathLength requires keyUsage asserting keyCertSign
policy_constraints_emptypolicyConstraints carries neither field
policy_mappings_any_policyanyPolicy may not appear in a policy mapping
policy_mappings_emptyMappings list is empty
reserved_policy_qualifier_oidCustom qualifier uses a reserved qualifier OID

micro509/verify

VerifyErrorCode

Meanings are tabled in the verification guide; both tables are enforced against VERIFY_ERROR_CODES by tests.

authority_key_identifier_mismatch, ca_required, certificate_expired, certificate_revoked, common_name_fallback_suppressed, ec_domain_parameters_missing, explicit_policy_required, extended_key_usage_invalid, initial_policy_set_not_satisfied, intermediate_eku_constraint, issuer_not_found, key_cert_sign_required, name_constraints_violated, no_trusted_root, path_length_exceeded, revocation_indeterminate, self_signed_leaf_not_allowed, signature_invalid, subject_alt_name_mismatch, unrecognized_critical_extension, unsupported_initial_name_constraints, unsupported_name_constraints, unsupported_signature_algorithm_parameters

MatchServiceIdentityErrorCode

CodeMeaning
common_name_fallback_suppressedCN match suppressed by presented identifiers
service_identity_mismatchSRV-ID or URI-ID service part does not match
subject_alt_name_mismatchNo SAN matches the requested identity
unsupported_service_identity_typeIdentity type has no matcher

micro509/revocation

ParseCertificateRevocationListErrorCode

CodeMeaning
malformedInput is not a valid DER or PEM CRL

ParseOcspRequestErrorCode

CodeMeaning
malformedInput is not a valid DER or PEM OCSP request

ParseOcspResponseErrorCode

CodeMeaning
malformedInput is not a valid DER or PEM OCSP response

CheckCertificateRevocationAgainstCrlErrorCode

CodeMeaning
crl_sign_not_permittedCRL signer's keyUsage lacks cRLSign
issuer_mismatchCRL issuer does not match the certificate's issuer
non_applicableNo supplied CRL applies to the certificate (RFC 5280 §6.3.3)
signature_invalidCRL signature fails against the issuer key
stale_crlCRL outside its thisUpdate/nextUpdate window

ValidateOcspResponseErrorCode

CodeMeaning
issuer_mismatchCertID does not hash to the supplied issuer
nonce_mismatchResponse nonce differs from the request's
ocsp_signing_missingDelegated responder lacks the ocspSigning EKU
request_mismatchResponse does not answer every requested CertID
responder_chain_invalidResponder certificate path fails validation
responder_id_mismatchResponderID matches no candidate signer
responder_revocation_unknownDelegated responder revocation status undetermined
responder_revokedDelegated responder certificate is revoked
response_status_invalidOCSPResponse status is not successful
signature_invalidResponse signature fails
stale_responseResponse outside its freshness window

CheckCertificateRevocationErrorCode

CodeMeaning
revocation_evidence_missingNo CRL or OCSP evidence was supplied
revocation_status_indeterminateEvidence yielded no verdict under the hard-fail policy

RevocationIndeterminateReasonCode

CodeMeaning
certificate_status_missingResponse carries no entry for the certificate
certificate_status_unknownResponder answered unknown
crl_sign_not_permittedCRL signer's keyUsage lacks cRLSign
issuer_mismatchEvidence issuer does not match the certificate's issuer
non_applicableNo supplied CRL applies to the certificate
nonce_mismatchResponse nonce differs from the request's
ocsp_signing_missingDelegated responder lacks the ocspSigning EKU
reason_coverage_incompleteApplicable CRLs cover only some CRLReasons
request_mismatchResponse does not answer the supplied request
responder_chain_invalidResponder certificate path fails validation
responder_id_mismatchResponderID matches no candidate signer
responder_revocation_unknownDelegated responder revocation status undetermined
responder_revokedDelegated responder certificate is revoked
response_status_invalidOCSPResponse status is not successful
signature_invalidEvidence signature fails
stale_crlCRL outside its thisUpdate/nextUpdate window
stale_responseResponse outside its freshness window

CrlEncoderErrorCode

CodeMeaning
distribution_point_full_name_emptyIDP fullName present but holds no GeneralName
issuer_distinguished_name_emptyRFC 5280 §5.1.2.3 requires a non-empty issuer DN

OcspEncoderErrorCode

CodeMeaning
signer_certificate_key_mismatchSigner certificate's SPKI does not match the signing key

micro509/keys

ImportKeyErrorCode

CodeMeaning
malformedKey material fails to parse or match the request

ImportEncryptedKeyErrorCode

CodeMeaning
invalid_passwordDecryption failed, or plaintext is not a private key
malformedEnvelope fails to parse before any decryption

EncryptRsaOaepErrorCode

CodeMeaning
invalid_keyKey is not an RSA-OAEP public key with encrypt usage
message_too_longPlaintext exceeds the OAEP capacity of the key

DecryptRsaOaepErrorCode

CodeMeaning
decryption_failedDeliberately opaque: wrong key, wrong label, or bad ciphertext
invalid_keyKey is not an RSA-OAEP private key with decrypt usage

micro509/pem

PemErrorCode

CodeMeaning
malformedEncapsulation or base64 violates RFC 7468 strict mode

micro509/der

DecodeDerErrorCode

CodeMeaning
malformedBytes are not the expected DER structure

micro509/pkcs

ParsePfxErrorCode

CodeMeaning
invalid_passwordMAC or decryption rejects the supplied password
malformedPFX structure fails to parse
password_requiredEncrypted content present but no password given

CreatePfxErrorCode

CodeMeaning
invalid_certificateA certificate source fails to parse

ParsePkcs12MacDataErrorCode

CodeMeaning
malformedMacData structure fails to parse

ParsePkcs7ErrorCode

CodeMeaning
malformedContentInfo or SignedData fails to parse
not_signed_dataContentInfo carries a content type other than data

CreatePkcs7CertBagErrorCode

CodeMeaning
invalid_certificateA certificate source fails to parse

CreatePkcs7SignedDataErrorCode

CodeMeaning
invalid_certificateAn additionalCertificates entry fails to parse
invalid_signer_certificateA signer's certificate source fails to parse
no_signerssigners is empty
signer_certificate_key_mismatchSigner certificate's SPKI does not match the signing key
unsupported_signer_keySigning key algorithm has no CMS digest mapping

VerifyPkcs7SignedDataErrorCode

CodeMeaning
detached_content_requiredSignedData has no eContent and no content option supplied
malformedStructure, attributes, or algorithms fail to process
message_digest_mismatchContent digest differs from the messageDigest attribute
not_signed_dataContentInfo carries a content type other than SignedData
signature_invalidA signer's signature does not verify
signer_not_foundNo embedded certificate matches a SignerInfo

Released under the MIT License.