XU XUv0.16.0

#crypto/x509

import: #crypto/x509

counts: 5 functions, 8 methods, 4 types, 39 constants, 0 method sets

Parse certificates and verify (Ed25519, RSA SHA-256, SM2-with-SM3). No issuance.

const UNKNOWN_SIGNATURE_ALGORITHM

XuAPI
pub const UNKNOWN_SIGNATURE_ALGORITHM = 0

Purpose

Constant UNKNOWN_SIGNATURE_ALGORITHM, defining protocol or algorithm parameters.

const MD5_WITH_RSA

XuAPI
pub const MD5_WITH_RSA = 2

Purpose

Constant MD5_WITH_RSA, defining protocol or algorithm parameters.

const SHA1_WITH_RSA

XuAPI
pub const SHA1_WITH_RSA = 3

Purpose

Constant SHA1_WITH_RSA, defining protocol or algorithm parameters.

const SHA256_WITH_RSA

XuAPI
pub const SHA256_WITH_RSA = 4

Purpose

Constant SHA256_WITH_RSA, defining protocol or algorithm parameters.

const SHA384_WITH_RSA

XuAPI
pub const SHA384_WITH_RSA = 5

Purpose

Constant SHA384_WITH_RSA, defining protocol or algorithm parameters.

const SHA512_WITH_RSA

XuAPI
pub const SHA512_WITH_RSA = 6

Purpose

Constant SHA512_WITH_RSA, defining protocol or algorithm parameters.

const ECDSA_WITH_SHA256

XuAPI
pub const ECDSA_WITH_SHA256 = 10

Purpose

Constant ECDSA_WITH_SHA256, defining protocol or algorithm parameters.

const ECDSA_WITH_SHA384

XuAPI
pub const ECDSA_WITH_SHA384 = 11

Purpose

Constant ECDSA_WITH_SHA384, defining protocol or algorithm parameters.

const ECDSA_WITH_SHA512

XuAPI
pub const ECDSA_WITH_SHA512 = 12

Purpose

Constant ECDSA_WITH_SHA512, defining protocol or algorithm parameters.

const PURE_ED25519

XuAPI
pub const PURE_ED25519 = 16

Purpose

Constant PURE_ED25519, defining protocol or algorithm parameters.

const SM2_WITH_SM3

XuAPI
pub const SM2_WITH_SM3 = 20

Purpose

Constant SM2_WITH_SM3, defining protocol or algorithm parameters.

const UNKNOWN_PUBLIC_KEY_ALGORITHM

XuAPI
pub const UNKNOWN_PUBLIC_KEY_ALGORITHM = 0

Purpose

Constant UNKNOWN_PUBLIC_KEY_ALGORITHM, defining protocol or algorithm parameters.

const RSA

XuAPI
pub const RSA = 1

Purpose

Constant RSA, defining protocol or algorithm parameters.

const DSA

XuAPI
pub const DSA = 2

Purpose

Constant DSA, defining protocol or algorithm parameters.

const ECDSA

XuAPI
pub const ECDSA = 3

Purpose

Constant ECDSA, defining protocol or algorithm parameters.

const ED25519

XuAPI
pub const ED25519 = 4

Purpose

Constant ED25519, defining protocol or algorithm parameters.

const SM2

XuAPI
pub const SM2 = 5

Purpose

Constant SM2, defining protocol or algorithm parameters.

const KEY_USAGE_DIGITAL_SIGNATURE

XuAPI
pub const KEY_USAGE_DIGITAL_SIGNATURE = 1

Purpose

RFC 5280 KeyUsage bit positions, aligned with crypto/x509.

const KEY_USAGE_CONTENT_COMMITMENT

XuAPI
pub const KEY_USAGE_CONTENT_COMMITMENT = 2

Purpose

Constant KEY_USAGE_CONTENT_COMMITMENT, defining protocol or algorithm parameters.

const KEY_USAGE_KEY_ENCIPHERMENT

XuAPI
pub const KEY_USAGE_KEY_ENCIPHERMENT = 4

Purpose

Constant KEY_USAGE_KEY_ENCIPHERMENT, defining protocol or algorithm parameters.

const KEY_USAGE_DATA_ENCIPHERMENT

XuAPI
pub const KEY_USAGE_DATA_ENCIPHERMENT = 8

Purpose

Constant KEY_USAGE_DATA_ENCIPHERMENT, defining protocol or algorithm parameters.

const KEY_USAGE_KEY_AGREEMENT

XuAPI
pub const KEY_USAGE_KEY_AGREEMENT = 16

Purpose

Constant KEY_USAGE_KEY_AGREEMENT, defining protocol or algorithm parameters.

const KEY_USAGE_CERT_SIGN

XuAPI
pub const KEY_USAGE_CERT_SIGN = 32

Purpose

Constant KEY_USAGE_CERT_SIGN, defining protocol or algorithm parameters.

const KEY_USAGE_CRL_SIGN

XuAPI
pub const KEY_USAGE_CRL_SIGN = 64

Purpose

Constant KEY_USAGE_CRL_SIGN, defining protocol or algorithm parameters.

const KEY_USAGE_ENCIPHER_ONLY

XuAPI
pub const KEY_USAGE_ENCIPHER_ONLY = 128

Purpose

Constant KEY_USAGE_ENCIPHER_ONLY, defining protocol or algorithm parameters.

const KEY_USAGE_DECIPHER_ONLY

XuAPI
pub const KEY_USAGE_DECIPHER_ONLY = 256

Purpose

Constant KEY_USAGE_DECIPHER_ONLY, defining protocol or algorithm parameters.

struct Certificate

XuAPI
pub struct Certificate {
    pub raw string
    pub raw_tbs_certificate string
    pub raw_subject_public_key_info string
    pub raw_subject string
    pub raw_issuer string
    pub signature string
    pub signature_algorithm int
    pub public_key_algorithm int
    pub public_key string
    pub version int
    pub serial_number big.Int
    pub serial_bytes string
    pub issuer pkix.Name
    pub subject pkix.Name
    pub not_before time.Time
    pub not_after time.Time
    pub is_ca bool
    pub basic_constraints_valid bool
    pub max_path_len int
    pub max_path_len_zero bool
    pub key_usage int
    pub key_usage_present bool
    pub subject_key_id string
    pub authority_key_id string
    pub ext_key_usage []int
    pub ext_key_usage_present bool
    pub has_unknown_ext_key_usage bool
    pub permitted_dns_domains []string
    pub excluded_dns_domains []string
    pub permitted_ip_ranges []string
    pub excluded_ip_ranges []string
    pub name_constraints_present bool
    pub name_constraints_unsupported bool
    pub certificate_policies []string
    pub certificate_policies_present bool
    pub policy_mapping_issuers []string
    pub policy_mapping_subjects []string
    pub policy_mappings_present bool
    pub require_explicit_policy int
    pub inhibit_policy_mapping int
    pub policy_constraints_present bool
    pub inhibit_any_policy int
    pub inhibit_any_policy_present bool
    pub has_unhandled_critical_extension bool
    pub dns_names []string
    pub ip_addresses []string
}

Purpose

Structure encapsulating raw, raw_tbs_certificate, raw_subject_public_key_info, raw_subject, raw_issuer.

Public fields

raw string
field (string)
raw_tbs_certificate string
field (string)
raw_subject_public_key_info string
field (string)
raw_subject string
field (string)
raw_issuer string
field (string)
signature string
field (string)
signature_algorithm int
field (int)
public_key_algorithm int
field (int)
public_key string
field (string)
version int
field (int)
serial_number big.Int
field (big.Int)
serial_bytes string
Canonical unsigned DER serial bytes (leading sign padding removed). Revocation checks use this representation to avoid integer-width drift.
issuer pkix.Name
field (pkix.Name)
subject pkix.Name
field (pkix.Name)
not_before time.Time
field (time.Time)
not_after time.Time
field (time.Time)
is_ca bool
field (bool)
basic_constraints_valid bool
field (bool)
max_path_len int
1 means absent/unlimited. max_path_len_zero distinguishes an explicit pathLenConstraint=0 from the absent default, matching shape.
max_path_len_zero bool
field (bool)
key_usage int
field (int)
key_usage_present bool
field (bool)
subject_key_id string
field (string)
authority_key_id string
field (string)
ext_key_usage []int
field ([]int)
ext_key_usage_present bool
field (bool)
has_unknown_ext_key_usage bool
field (bool)
permitted_dns_domains []string
field ([]string)
excluded_dns_domains []string
field ([]string)
permitted_ip_ranges []string
Raw RFC 5280 iPAddress constraints: address || mask (8 or 32 bytes).
excluded_ip_ranges []string
field ([]string)
name_constraints_present bool
field (bool)
name_constraints_unsupported bool
field (bool)
certificate_policies []string
field ([]string)
certificate_policies_present bool
field (bool)
policy_mapping_issuers []string
field ([]string)
policy_mapping_subjects []string
field ([]string)
policy_mappings_present bool
field (bool)
require_explicit_policy int
field (int)
inhibit_policy_mapping int
field (int)
policy_constraints_present bool
field (bool)
inhibit_any_policy int
field (int)
inhibit_any_policy_present bool
field (bool)
has_unhandled_critical_extension bool
Safe fail-closed marker for critical extensions this subset does not yet process. Path validation rejects such certificates.
dns_names []string
field ([]string)
ip_addresses []string
Raw network-order addresses from subjectAltName iPAddress entries. IPv4 values contain 4 bytes and IPv6 values contain 16 bytes, matching the representation used by package net.

struct CertPool

XuAPI
pub struct CertPool {
    pub certs []Certificate
}

Purpose

X509 Connection pool manager scheduling reusable socket connections.

Public fields

certs []Certificate
field ([]Certificate)

struct VerifyOptions

XuAPI
pub struct VerifyOptions {
    pub dns_name string
    pub current_time time.Time
    pub roots CertPool
    pub intermediates CertPool
    pub key_usages []int
    pub certificate_policies []string
    pub revocation_lists []string
    pub revocation_mode int
}

Purpose

X509 Configuration parameters and options set.

Public fields

dns_name string
field (string)
current_time time.Time
field (time.Time)
roots CertPool
field (CertPool)
intermediates CertPool
field (CertPool)
key_usages []int
Empty defaults to ServerAuth, matching crypto/x509 VerifyOptions.
certificate_policies []string
Empty is the RFC 5280 anyPolicy initial-policy-set.
revocation_lists []string
DER-encoded CRLs supplied by the caller. Revocation is disabled by default; parsing inside each candidate edge avoids owning-struct moves.
revocation_mode int
field (int)

new_cert_pool

XuAPI
pub fn new_cert_pool() CertPool

Purpose

Construct cert pool.

Parameters

No arguments are required.

Returns

CertPool — a value of this type

($&CertPool) add

XuAPI
pub fn (p $&CertPool) add(c Certificate)

Purpose

Operation on $&CertPool: add.

Parameters

p $&CertPool
The CertPool instance used by this call (exclusive borrow).
c Certificate
byte or character code (Certificate)

Returns

This call does not return a value.

append_certificates

XuAPI
pub fn append_certificates(p $&CertPool, pem_data &string) int

Purpose

append_certificates adds every CERTIFICATE PEM block that can be parsed. Unknown or malformed blocks are skipped, matching the useful part of AppendCertsFromPEM contract while keeping the subset's explicit count for diagnostics. The scanner keeps an offset into the original bundle and only copies one PEM block at a time. In particular, it does not repeatedly copy encoding/pem.Block.rest, which would make large system bundles quadratic.

Parameters

p $&CertPool
p (exclusive borrow; may modify the original; type $&CertPool)
pem_data &string
pem_data (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&CertPool) clone

XuAPI
pub fn (p &CertPool) clone() CertPool

Purpose

Operation on &CertPool: copy into a new independent string.

Parameters

p &CertPool
The CertPool instance used by this call (borrow).

Returns

CertPool — a value of this type

system_cert_pool

XuAPI
pub fn system_cert_pool() CertPool

Purpose

system_cert_pool probes the environment override first, then the native platform trust source, then conventional Unix PEM bundles and CA directories. The native adapter only supplies opaque DER records; parsing and trust policy remain in this package. An empty pool is returned when no source is readable, so TLS callers fail closed instead of silently disabling verification.

Parameters

No arguments are required.

Returns

CertPool — a value of this type

parse_certificate

XuAPI
pub fn parse_certificate(der string) Certificate

Purpose

Parse as certificate. Throws on failure; handle the error or propagate it to the caller.

Parameters

der string
der (string)

Returns

Certificate — a value of this type

(&Certificate) check_signature

XuAPI
pub fn (c &Certificate) check_signature(algo int, signed &string, signature &string) int

Purpose

Operation on &Certificate: check signature. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
algo int
algo (int)
signed &string
signed (read-only borrow; caller keeps the original; type &string)
signature &string
signature (read-only borrow; caller keeps the original; type &string)

Returns

int — a value of this type

(&Certificate) check_signature_from

XuAPI
pub fn (c &Certificate) check_signature_from(parent &Certificate) int

Purpose

Operation on &Certificate: check signature from. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
parent &Certificate
parent (read-only borrow; caller keeps the original; type &Certificate)

Returns

int — a value of this type

(&Certificate) match_host

XuAPI
pub fn (c &Certificate) match_host(host string) bool

Purpose

Operation on &Certificate: match host.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
host string
host (string)

Returns

bool — true or false

(&Certificate) verify_with_pools

XuAPI
pub fn (c &Certificate) verify_with_pools(dns_name string, current_time time.Time, roots &CertPool, intermediates &CertPool) int

Purpose

Operation on &Certificate: verify with pools. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
dns_name string
dns_name (string)
current_time time.Time
current_time (time.Time)
roots &CertPool
roots (read-only borrow; caller keeps the original; type &CertPool)
intermediates &CertPool
intermediates (read-only borrow; caller keeps the original; type &CertPool)

Returns

int — a value of this type

(&Certificate) verify_options

XuAPI
pub fn (c &Certificate) verify_options(opts &VerifyOptions) int

Purpose

verify_options borrows reusable verification inputs. This is the preferred form for callers that validate repeatedly against one pool or CRL set. Throws on failure; handle the error or propagate it to the caller.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
opts &VerifyOptions
opts (read-only borrow; caller keeps the original; type &VerifyOptions)

Returns

int — a value of this type

(&Certificate) verify

XuAPI
pub fn (c &Certificate) verify(opts VerifyOptions) int

Purpose

verify retains the original consuming API for source compatibility.

Parameters

c &Certificate
The Certificate instance used by this call (borrow).
opts VerifyOptions
opts (VerifyOptions)

Returns

int — a value of this type

const EXT_KEY_USAGE_ANY

XuAPI
pub const EXT_KEY_USAGE_ANY = 0

Purpose

ExtendedKeyUsage values match crypto/x509 where the API overlaps.

const EXT_KEY_USAGE_SERVER_AUTH

XuAPI
pub const EXT_KEY_USAGE_SERVER_AUTH = 1

Purpose

Constant EXT_KEY_USAGE_SERVER_AUTH, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_CLIENT_AUTH

XuAPI
pub const EXT_KEY_USAGE_CLIENT_AUTH = 2

Purpose

Constant EXT_KEY_USAGE_CLIENT_AUTH, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_CODE_SIGNING

XuAPI
pub const EXT_KEY_USAGE_CODE_SIGNING = 3

Purpose

Constant EXT_KEY_USAGE_CODE_SIGNING, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_EMAIL_PROTECTION

XuAPI
pub const EXT_KEY_USAGE_EMAIL_PROTECTION = 4

Purpose

Constant EXT_KEY_USAGE_EMAIL_PROTECTION, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_IPSEC_END_SYSTEM

XuAPI
pub const EXT_KEY_USAGE_IPSEC_END_SYSTEM = 5

Purpose

Constant EXT_KEY_USAGE_IPSEC_END_SYSTEM, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_IPSEC_TUNNEL

XuAPI
pub const EXT_KEY_USAGE_IPSEC_TUNNEL = 6

Purpose

Constant EXT_KEY_USAGE_IPSEC_TUNNEL, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_IPSEC_USER

XuAPI
pub const EXT_KEY_USAGE_IPSEC_USER = 7

Purpose

Constant EXT_KEY_USAGE_IPSEC_USER, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_TIME_STAMPING

XuAPI
pub const EXT_KEY_USAGE_TIME_STAMPING = 8

Purpose

Constant EXT_KEY_USAGE_TIME_STAMPING, defining protocol or algorithm parameters.

const EXT_KEY_USAGE_OCSP_SIGNING

XuAPI
pub const EXT_KEY_USAGE_OCSP_SIGNING = 9

Purpose

Constant EXT_KEY_USAGE_OCSP_SIGNING, defining protocol or algorithm parameters.

const REVOCATION_OFF

XuAPI
pub const REVOCATION_OFF = 0

Purpose

Constant REVOCATION_OFF, defining protocol or algorithm parameters.

const REVOCATION_IF_PRESENT

XuAPI
pub const REVOCATION_IF_PRESENT = 1

Purpose

Constant REVOCATION_IF_PRESENT, defining protocol or algorithm parameters.

const REVOCATION_REQUIRE

XuAPI
pub const REVOCATION_REQUIRE = 2

Purpose

Constant REVOCATION_REQUIRE, defining protocol or algorithm parameters.

struct RevocationList

XuAPI
pub struct RevocationList {
    pub raw string
    pub raw_tbs string
    pub raw_issuer string
    pub signature string
    pub signature_algorithm int
    pub this_update time.Time
    pub next_update time.Time
    pub next_update_present bool
    pub authority_key_id string
    pub number int
    pub revoked_serials []string
    pub has_unhandled_critical_extension bool
}

Purpose

Structure encapsulating raw, raw_tbs, raw_issuer, signature, signature_algorithm.

Public fields

raw string
field (string)
raw_tbs string
field (string)
raw_issuer string
field (string)
signature string
field (string)
signature_algorithm int
field (int)
this_update time.Time
field (time.Time)
next_update time.Time
field (time.Time)
next_update_present bool
field (bool)
authority_key_id string
field (string)
number int
field (int)
revoked_serials []string
field ([]string)
has_unhandled_critical_extension bool
field (bool)

parse_revocation_list

XuAPI
pub fn parse_revocation_list(der string) RevocationList

Purpose

Parse as revocation list. Throws on failure; handle the error or propagate it to the caller.

Parameters

der string
der (string)

Returns

RevocationList — a value of this type