pub struct EnrollmentSession { /* private fields */ }Expand description
Client-side NDNCERT enrollment session.
Usage:
- Create with
EnrollmentSession::new - Call
new_request_bodyto get the body for the/CA/NEWInterest - Feed the response to
handle_new_response - Build the challenge parameters and call
challenge_request_body - Feed the response to
handle_challenge_response - For multi-round challenges (email), repeat steps 4–5 with updated parameters
- On success, retrieve the certificate with
certificate
Implementations§
Source§impl EnrollmentSession
impl EnrollmentSession
pub fn new(name: Name, public_key: Vec<u8>, validity_secs: u64) -> Self
Sourcepub fn new_request_body(&mut self) -> Result<Vec<u8>, CertError>
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.
Sourcepub fn handle_new_response(&mut self, body: &[u8]) -> Result<(), CertError>
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.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The request ID assigned by the CA (available after handle_new_response).
Sourcepub fn offered_challenges(&self) -> &[String]
pub fn offered_challenges(&self) -> &[String]
The challenge types offered by the CA.
Sourcepub fn challenge_status_message(&self) -> Option<&str>
pub fn challenge_status_message(&self) -> Option<&str>
Status message from an in-progress challenge (e.g. “Code sent to user@example.com”).
Sourcepub fn remaining_tries(&self) -> Option<u8>
pub fn remaining_tries(&self) -> Option<u8>
Remaining attempts for an in-progress challenge.
Sourcepub fn challenge_request_body(
&self,
challenge_type: &str,
parameters: Map<String, Value>,
) -> Result<Vec<u8>, CertError>
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.
Sourcepub fn handle_challenge_response(
&mut self,
body: &[u8],
) -> Result<(), CertError>
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.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Whether the session has completed successfully.
Sourcepub fn needs_another_round(&self) -> bool
pub fn needs_another_round(&self) -> bool
Whether another CHALLENGE round is required.
Sourcepub fn certificate(&self) -> Option<&Certificate>
pub fn certificate(&self) -> Option<&Certificate>
The issued certificate (available after successful completion).
Sourcepub fn into_certificate(self) -> Option<Certificate>
pub fn into_certificate(self) -> Option<Certificate>
Consume the session and return the issued certificate.