Skip to main content

Certificate

Struct Certificate 

Source
pub struct Certificate { /* private fields */ }
Expand description

Ed25519 の鍵の X.509 の証明書。

Implementations§

Source§

impl Certificate

Source

pub fn self_signed( key: &PrivateKey, template: &Template<'_>, ) -> Result<Self, IssueError>

自己署名の証明書を発行する。ノードの CA の証明書になる。

Source

pub fn issue( ca: &Certificate, ca_key: &PrivateKey, public_key: &PublicKey, template: &Template<'_>, ) -> Result<Self, IssueError>

ca の鍵で public_key に証明書を発行する。issuer には ca の subject を使う。

ca_key が ca の公開鍵と組でなければ発行しない。

Source

pub fn renew( &self, ca: &Certificate, ca_key: &PrivateKey, not_before: SystemTime, not_after: SystemTime, serial_number: &[u8], ) -> Result<Self, IssueError>

この証明書と同じ subject、公開鍵、バージョンで、ca の鍵で発行し直す。ノードの証明書の更新に使う。

ca_key が ca の公開鍵と組でなければ発行しない。v2 の証明書は v3 として発行し直す。

Source

pub fn from_der(der: &[u8]) -> Result<Self, ParseCertificateError>

DER から読む。DER として正規でないもの、Ed25519 の鍵と署名でないものは受け付けない。

Source

pub fn from_pem(pem: &str) -> Result<Self, ParseCertificateError>

-----BEGIN CERTIFICATE----- の PEM から読む。

Source

pub fn from_pem_chain(pem: &str) -> Result<Vec<Self>, ParseCertificateError>

PEM の証明書をつないだもの(node.full.crt.pem など)を、書かれた順に読む。

Source

pub fn to_der(&self) -> &[u8] ⓘ

Source

pub fn to_pem(&self) -> String

PEM にする。末尾に改行は付けない。

Source

pub fn version(&self) -> u8

1、2、3 のどれか。

Source

pub fn serial_number(&self) -> &[u8] ⓘ

先頭の0を除いた、符号なしの大きな整数のバイト列。

Source

pub fn issuer(&self) -> String

RFC 4514 の DN。

Source

pub fn subject(&self) -> String

RFC 4514 の DN。

Source

pub fn not_before(&self) -> SystemTime

Source

pub fn not_after(&self) -> SystemTime

Source

pub fn public_key(&self) -> &PublicKey

Source

pub fn is_signed_by(&self, issuer: &PublicKey) -> bool

issuer の鍵で署名されているか。

判定には catapult の署名の検証を使う。catapult がつなぐときの証明書の署名は OpenSSL が確かめるので、境界のケースでは判定が少し違いうる。

Source

pub fn is_self_signed(&self) -> bool

issuer と subject が同じで、自分の鍵で署名されているか。

Trait Implementations§

Source§

impl Clone for Certificate

Source§

fn clone(&self) -> Certificate

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Certificate

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
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. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

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

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.