跳到主要内容

CertificateParams

搜索

结构体 CertificateParams 

Source
#[non_exhaustive]
pub struct CertificateParams {
Show 13 fields pub not_before: OffsetDateTime, pub not_after: OffsetDateTime, pub serial_number: Option<SerialNumber>, pub subject_alt_names: Vec<SanType>, pub distinguished_name: DistinguishedName, pub is_ca: IsCa, pub key_usages: Vec<KeyUsagePurpose>, pub extended_key_usages: Vec<ExtendedKeyUsagePurpose>, pub name_constraints: Option<NameConstraints>, pub crl_distribution_points: Vec<CrlDistributionPoint>, pub custom_extensions: Vec<CustomExtension>, pub use_authority_key_identifier_extension: bool, pub key_identifier_method: KeyIdMethod,
}
展开描述

用于生成证书的参数

字段 (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§not_before: OffsetDateTime§not_after: OffsetDateTime§serial_number: Option<SerialNumber>§subject_alt_names: Vec<SanType>§distinguished_name: DistinguishedName§is_ca: IsCa§key_usages: Vec<KeyUsagePurpose>§extended_key_usages: Vec<ExtendedKeyUsagePurpose>§name_constraints: Option<NameConstraints>§crl_distribution_points: Vec<CrlDistributionPoint>

如 RFC 5280 第 4.2.1.13 节所述的证书吊销列表(CRL)分发点的可选列表1. 每个分发点包含一个或多个 URI,可从这些 URI 处获取最新的 CRLcope including this certificate can be retrieved.

§custom_extensions: Vec<CustomExtension>§use_authority_key_identifier_extension: bool

true,则会在生成的证书中加入 ‘Authority Key Identifier’(颁发者密钥标识符)扩展

§key_identifier_method: KeyIdMethod

从公钥生成密钥标识符的方法

默认为截取的 SHA-256 摘要。详见 KeyIdMethod

实现§

Source§

impl CertificateParams

Source

pub fn new(subject_alt_names: impl Into<Vec<String>>) -> Result<Self, Error>

使用合理的默认值生成证书参数

Source

pub fn signed_by( &self, public_key: &impl PublicKeyData, issuer: &Issuer<'_, impl SigningKey>, ) -> Result<Certificate, Error>

根据给定参数生成一份新证书,由所提供的颁发者签名。

返回的证书将其 issuer 字段设置为所提供的 issuer 的 subject,并使用 issuer 的主体公钥(通常为 CertificateParamsCertificate)填充 authority key identifier 扩展。它将由 issuer_key 签名。

注意,不会对 issuer 证书进行任何验证。Rcgen 不要求该证书是 CA 证书,也不要求其具有允许签名的密钥用途扩展。

返回的 Certificate 可通过 Certificate::derCertificate::pem 序列化。

Source

pub fn self_signed( &self, signing_key: &impl SigningKey, ) -> Result<Certificate, Error>

根据给定参数生成一份新的自签名证书。

返回的 Certificate 可通过 Certificate::derCertificate::pem 序列化。

Source

pub fn key_identifier(&self, key: &impl PublicKeyData) -> Vec<u8>

为证书主体的公钥计算 subject key identifier。该密钥标识符用于 SubjectKeyIdentifier X.509v3 扩展中。

Source

pub fn serialize_request( &self, subject_key: &impl SigningKey, ) -> Result<CertificateSigningRequest, Error>

生成并将一个证书签名请求(CSR)序列化。

所构造的 CSR 将包含基于证书参数的属性,并包含来自 subject_key 的主体公钥信息。此外,CSR 将使用主体密钥签名。

注意,后续对 serialize_request() 的调用不会产生完全相同的输出。

Source

pub fn serialize_request_with_attributes( &self, subject_key: &impl SigningKey, attrs: Vec<Attribute>, ) -> Result<CertificateSigningRequest, Error>

RFC 2986 中定义的、带有自定义 PKCS #10 属性的方式,生成并序列化证书签名请求(CSR)。

所构造的 CSR 将包含基于证书参数的属性,并包含来自 subject_key 的主体公钥信息。此外,CSR 将使用主体密钥自签名。

注意,后续对 serialize_request_with_attributes() 的调用不会产生完全相同的输出。

Source

pub fn insert_extended_key_usage(&mut self, eku: ExtendedKeyUsagePurpose)

若参数中尚未存在指定的 extended key usage(EKU),则将其插入

Trait 实现§

Source§

impl AsRef<CertificateParams> for CertificateParams

Source§

fn as_ref(&self) -> &CertificateParams

将此类型转换为输入类型的共享引用(通常自动推导)。
Source§

impl Clone for CertificateParams

Source§

fn clone(&self) -> CertificateParams

返回值的副本。 更多信息
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 更多信息
Source§

impl Debug for CertificateParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

使用给定的格式化器格式化此值。 更多信息
Source§

impl Default for CertificateParams

Source§

fn default() -> Self

Returns the “default value” for a type. 更多信息
Source§

impl PartialEq for CertificateParams

Source§

fn eq(&self, other: &CertificateParams) -> bool

测试 selfother 值是否相等,供 == 运算符使用。
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

测试 != 运算符。默认实现几乎总是够用,除非有非常充分的理由,否则不应被覆盖。
Source§

impl Eq for CertificateParams

Source§

impl StructuralPartialEq for CertificateParams

自动 Trait 实现§

Blanket 实现§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 更多信息
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回传入的参数。

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

调用 U::from(self)

That is, this conversion is whatever the implementation of From<T> for U 的实现方式。

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

获得所有权后的类型。
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 更多信息
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。