EnrollmentSession

Struct EnrollmentSession 

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

Client-side NDNCERT enrollment session.

Usage:

  1. Create with EnrollmentSession::new
  2. Call new_request_body to get the body for the /CA/NEW Interest
  3. Feed the response to handle_new_response
  4. Build the challenge parameters and call challenge_request_body
  5. Feed the response to handle_challenge_response
  6. For multi-round challenges (email), repeat steps 4–5 with updated parameters
  7. On success, retrieve the certificate with certificate

Implementations§

Source§

impl EnrollmentSession

Source

pub fn new(name: Name, public_key: Vec<u8>, validity_secs: u64) -> Self

Source

pub fn new_request_body(&mut self) -> Result<Vec<u8>, CertError>

Build the TLV body for the /CA/NEW Interest’s ApplicationParameters.

Generates a fresh P-256 ephemeral ECDH key pair; the private part is held in self until the CA responds with its own public key.

Source

pub fn handle_new_response(&mut self, body: &[u8]) -> Result<(), CertError>

Process the /CA/NEW TLV response and advance state.

Performs ECDH key agreement with the CA’s ephemeral public key and derives the shared AES-GCM-128 session key.

Source

pub fn request_id(&self) -> Option<&str>

The request ID assigned by the CA (available after handle_new_response).

Source

pub fn offered_challenges(&self) -> &[String]

The challenge types offered by the CA.

Source

pub fn challenge_status_message(&self) -> Option<&str>

Status message from an in-progress challenge (e.g. “Code sent to user@example.com”).

Source

pub fn remaining_tries(&self) -> Option<u8>

Remaining attempts for an in-progress challenge.

Source

pub fn challenge_request_body( &self, challenge_type: &str, parameters: Map<String, Value>, ) -> Result<Vec<u8>, CertError>

Build the TLV body for the /CA/CHALLENGE/<id> Interest.

parameters is JSON-encoded and AES-GCM encrypted with the session key.

Source

pub fn handle_challenge_response( &mut self, body: &[u8], ) -> Result<(), CertError>

Process the challenge TLV response and advance state.

Returns Ok(()) on both success and Pending (another round needed). Check is_complete to know if the session is done. Check challenge_status_message for the next prompt.

Source

pub fn is_complete(&self) -> bool

Whether the session has completed successfully.

Source

pub fn needs_another_round(&self) -> bool

Whether another CHALLENGE round is required.

Source

pub fn certificate(&self) -> Option<&Certificate>

The issued certificate (available after successful completion).

Source

pub fn into_certificate(self) -> Option<Certificate>

Consume the session and return the issued certificate.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more