pub struct PkiClient {
pub ea_url: String,
pub aa_url: String,
pub ea_cert: Certificate,
pub aa_cert: Certificate,
pub rca_cert: Certificate,
pub certs_dir: PathBuf,
pub its_id: Vec<u8>,
pub backend: EcdsaBackend,
pub pop: bool,
pub enrolment_retry: Option<RetryPolicy>,
pub authorization_retry: Option<RetryPolicy>,
pub sleep: PkiSleep,
/* private fields */
}Expand description
ITS-S PKI client (see the module documentation).
Fields§
§ea_url: StringAccess points of the EA and the AA (the requests are POSTed to them).
aa_url: String§ea_cert: Certificate§aa_cert: Certificate§rca_cert: Certificate§certs_dir: PathBuf§its_id: Vec<u8>Canonical identifier (InnerEcRequest.itsId of an initial request).
backend: EcdsaBackend§pop: boolSend authorization requests with proof of possession (clause 6.2.3.3.1).
enrolment_retry: Option<RetryPolicy>Repetition of an enrolment request without response (ETSI TS 103 601 V2.1.1 clause 5.1, mandatory for every ITS-S); None sends it once.
Repetition of an authorization request (clause 5.2): for an ITS-S without privacy requirements only, hence off (None) by default.
sleep: PkiSleepWait between two transmissions (std::thread::sleep by default).
Implementations§
Source§impl PkiClient
impl PkiClient
Sourcepub fn new(
ea_url: impl Into<String>,
aa_url: impl Into<String>,
ea_cert: Certificate,
aa_cert: Certificate,
rca_cert: Certificate,
canonical_key_bytes: Option<Vec<u8>>,
certs_dir: impl Into<PathBuf>,
its_id: Option<[u8; 8]>,
http_timeout_secs: Option<u64>,
) -> Self
pub fn new( ea_url: impl Into<String>, aa_url: impl Into<String>, ea_cert: Certificate, aa_cert: Certificate, rca_cert: Certificate, canonical_key_bytes: Option<Vec<u8>>, certs_dir: impl Into<PathBuf>, its_id: Option<[u8; 8]>, http_timeout_secs: Option<u64>, ) -> Self
A client; canonical_key_bytes is the private scalar of the canonical key
registered with the EA (a key is generated without it, see
PkiClient::canonical_public_key). http_timeout_secs configures the
default HTTP transport.
Sourcepub fn with_transport(self, transport: Box<dyn PkiTransport>) -> Self
pub fn with_transport(self, transport: Box<dyn PkiTransport>) -> Self
Use transport instead of HTTP.
Sourcepub fn with_clock(self, clock: PkiClock) -> Self
pub fn with_clock(self, clock: PkiClock) -> Self
Use clock (UTC seconds) instead of the system time.
Sourcepub fn with_its_id(self, its_id: Vec<u8>) -> Self
pub fn with_its_id(self, its_id: Vec<u8>) -> Self
Canonical identifier of any length (default: 8 octets given to new).
Sourcepub fn ec(&self) -> Option<&OwnCertificate>
pub fn ec(&self) -> Option<&OwnCertificate>
The current EC, if valid.
Sourcepub fn at(&self) -> Option<&OwnCertificate>
pub fn at(&self) -> Option<&OwnCertificate>
The current AT, if valid (and the EC too).
Sourcepub fn canonical_public_key(&self) -> PublicVerificationKey
pub fn canonical_public_key(&self) -> PublicVerificationKey
The canonical verification key (to be registered with the EA).
Sourcepub fn revoke(&mut self, revoked: &HashSet<[u8; 8]>)
pub fn revoke(&mut self, revoked: &HashSet<[u8; 8]>)
Apply revoked CA certificates (HashedId8): an EC whose EA or Root CA is
revoked is dropped (initialized); an AT whose AA (or Root CA) is
revoked is dropped (enrolled).
Sourcepub fn enroll(
&mut self,
app_permissions: Option<SequenceOfPsidSsp>,
validity_years: Option<u16>,
) -> Result<OwnCertificate, PkiError>
pub fn enroll( &mut self, app_permissions: Option<SequenceOfPsidSsp>, validity_years: Option<u16>, ) -> Result<OwnCertificate, PkiError>
Request an EC (clause 6.2.3.2): a re-keying request when the current EC
is valid and permits enrolment requests, an initial request otherwise.
The EC is saved to <certs_dir>/ec.{cert,pem}.
Request an AT (clause 6.2.3.3) with the EC (ecSignature). The AT is
saved to <certs_dir>/at.{cert,pem}.
Sourcepub fn provision(
&mut self,
app_permissions: Option<SequenceOfPsidSsp>,
ec_validity_years: Option<u16>,
at_validity_hours: Option<u16>,
) -> Result<OwnCertificate, PkiError>
pub fn provision( &mut self, app_permissions: Option<SequenceOfPsidSsp>, ec_validity_years: Option<u16>, at_validity_hours: Option<u16>, ) -> Result<OwnCertificate, PkiError>
Enrol (when not enrolled) and request an AT; returns the AT.
Sourcepub fn save_cert(
&self,
cert: &OwnCertificate,
name: &str,
) -> Result<(), PkiError>
pub fn save_cert( &self, cert: &OwnCertificate, name: &str, ) -> Result<(), PkiError>
Save a certificate (COER) and its private scalar to
<certs_dir>/<name>.cert and <certs_dir>/<name>.pem.
Sourcepub fn load_ec_from_disk(
&mut self,
name: Option<&str>,
) -> Option<OwnCertificate>
pub fn load_ec_from_disk( &mut self, name: Option<&str>, ) -> Option<OwnCertificate>
Load a previously issued EC (None if absent or unreadable).
Sourcepub fn load_at_from_disk(
&mut self,
name: Option<&str>,
) -> Option<OwnCertificate>
pub fn load_at_from_disk( &mut self, name: Option<&str>, ) -> Option<OwnCertificate>
Load a previously issued AT (None if absent or unreadable).
Auto Trait Implementations§
impl !Freeze for PkiClient
impl !RefUnwindSafe for PkiClient
impl Send for PkiClient
impl Sync for PkiClient
impl Unpin for PkiClient
impl UnsafeUnpin for PkiClient
impl !UnwindSafe for PkiClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.