#[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
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>若 true,则会在生成的证书中加入 ‘Authority Key Identifier’(颁发者密钥标识符)扩展
key_identifier_method: KeyIdMethod从公钥生成密钥标识符的方法
默认为截取的 SHA-256 摘要。详见 KeyIdMethod。
实现§
Source§impl CertificateParams
impl CertificateParams
Sourcepub fn signed_by(
&self,
public_key: &impl PublicKeyData,
issuer: &Issuer<'_, impl SigningKey>,
) -> Result<Certificate, Error>
pub fn signed_by( &self, public_key: &impl PublicKeyData, issuer: &Issuer<'_, impl SigningKey>, ) -> Result<Certificate, Error>
根据给定参数生成一份新证书,由所提供的颁发者签名。
返回的证书将其 issuer 字段设置为所提供的 issuer 的 subject,并使用 issuer 的主体公钥(通常为 CertificateParams 或 Certificate)填充 authority key identifier 扩展。它将由 issuer_key 签名。
注意,不会对 issuer 证书进行任何验证。Rcgen 不要求该证书是 CA 证书,也不要求其具有允许签名的密钥用途扩展。
返回的 Certificate 可通过 Certificate::der 与 Certificate::pem 序列化。
Sourcepub fn self_signed(
&self,
signing_key: &impl SigningKey,
) -> Result<Certificate, Error>
pub fn self_signed( &self, signing_key: &impl SigningKey, ) -> Result<Certificate, Error>
根据给定参数生成一份新的自签名证书。
返回的 Certificate 可通过 Certificate::der 与 Certificate::pem 序列化。
Sourcepub fn key_identifier(&self, key: &impl PublicKeyData) -> Vec<u8> ⓘ
pub fn key_identifier(&self, key: &impl PublicKeyData) -> Vec<u8> ⓘ
为证书主体的公钥计算 subject key identifier。该密钥标识符用于 SubjectKeyIdentifier X.509v3 扩展中。
Sourcepub fn serialize_request(
&self,
subject_key: &impl SigningKey,
) -> Result<CertificateSigningRequest, Error>
pub fn serialize_request( &self, subject_key: &impl SigningKey, ) -> Result<CertificateSigningRequest, Error>
生成并将一个证书签名请求(CSR)序列化。
所构造的 CSR 将包含基于证书参数的属性,并包含来自 subject_key 的主体公钥信息。此外,CSR 将使用主体密钥签名。
注意,后续对 serialize_request() 的调用不会产生完全相同的输出。
Sourcepub fn serialize_request_with_attributes(
&self,
subject_key: &impl SigningKey,
attrs: Vec<Attribute>,
) -> Result<CertificateSigningRequest, Error>
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() 的调用不会产生完全相同的输出。
Sourcepub fn insert_extended_key_usage(&mut self, eku: ExtendedKeyUsagePurpose)
pub fn insert_extended_key_usage(&mut self, eku: ExtendedKeyUsagePurpose)
若参数中尚未存在指定的 extended key usage(EKU),则将其插入
Trait 实现§
Source§impl AsRef<CertificateParams> for CertificateParams
impl AsRef<CertificateParams> for CertificateParams
Source§fn as_ref(&self) -> &CertificateParams
fn as_ref(&self) -> &CertificateParams
Source§impl Clone for CertificateParams
impl Clone for CertificateParams
Source§fn clone(&self) -> CertificateParams
fn clone(&self) -> CertificateParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. 更多信息