Skip to main content

HttpsClientBuilder

Struct HttpsClientBuilder 

Source
pub struct HttpsClientBuilder { /* private fields */ }
Available on crate feature client only.
Expand description

Builder for HttpsClient.

Implementations§

Source§

impl HttpsClientBuilder

Source

pub fn server_url(self, url: impl Into<String>) -> Self

Base URL of the server, e.g. "https://server.example". The client will POST to <server_url>/trust-tasks.

It must be https. A plain http URL is accepted when its host is loopback (localhost, 127.0.0.0/8, [::1] — local servers and tests), or elsewhere with Self::allow_insecure_http; a bearer token is never sent to a non-loopback http URL.

Source

pub fn server_vid(self, vid: impl Into<String>) -> Self

VID of the server, used as the in-band recipient on outbound documents and cross-checked with what the transport identifies as the peer.

Source

pub fn my_vid(self, vid: impl Into<String>) -> Self

VID of this client, used as the in-band issuer.

Source

pub fn my_token(self, token: impl Into<String>) -> Self

Bearer token sent in Authorization: Bearer <token>. The server resolves the token to a VID and uses that as the transport- authenticated sender for §4.8.1 precedence.

Source

pub fn strip_redundant_in_band(self, strip: bool) -> Self

If true, the client strips in-band issuer/recipient when they match my_vid/server_vid respectively (SPEC §9.2 item 1). Defaults to false: the safe behavior is to leave the in-band members in place so the document remains self-contained at rest.

Source

pub fn timeout(self, timeout: Duration) -> Self

End-to-end request timeout. Defaults to DEFAULT_TIMEOUT.

Source

pub fn connect_timeout(self, timeout: Duration) -> Self

Connection-establishment timeout. Defaults to DEFAULT_CONNECT_TIMEOUT.

Source

pub fn max_response_bytes(self, limit: usize) -> Self

The largest response body the client reads, in bytes. A larger one fails with ClientError::ResponseTooLarge as soon as it is detected, without buffering the rest. Defaults to DEFAULT_MAX_RESPONSE_BYTES.

Source

pub fn allow_insecure_http(self, allow: bool) -> Self

Accept a plain http Self::server_url whose host is not loopback. The document then crosses the network unencrypted. Even so, a configured Self::my_token is refused over it: Self::build fails rather than send the token in the clear.

Source

pub fn follow_redirects(self, follow: bool) -> Self

Follow redirects to the same origin (scheme, host and port), at most five. Off by default: a 3xx is returned as ClientError::HttpStatus, so a signed document is never re-posted to a URL other than the one configured. A redirect to another origin is never followed.

Source

pub fn with_response_verifier<V>(self, verifier: V) -> Self
where V: ProofVerifier + Send + Sync + 'static,

Verify the proof on every response document.

Off by default, and off is not the same as safe: with no verifier the client checks nothing cryptographic about what came back. The correlation checks HttpsClient::send performs — threadId, type, issuer, recipient — bind a response to its request, but they are all assertions by whoever answered the socket.

Configuring a verifier expresses “I require signed responses”: a proofless response is then rejected with ClientError::ResponseProofMissing rather than quietly accepted, because a downgrade that goes unnoticed is worth no more than no verification at all. Note the bundled HttpsServer does not sign its responses, so this is for peers that do.

The proof is verified over the response body exactly as received, never a re-serialisation of it, so a peer’s own spelling of a timestamp or member order does not break a valid signature.

Error responses are held to it too. A trust-task-error is returned as ClientError::TrustTaskError only when its proof verifies and its issuer / recipient match the configured VIDs, as a success response’s must. Anything else — an unsigned error, a bad proof, an error from another party — is returned as ClientError::UnverifiedErrorResponse: the body is kept for logging, but nothing about it is attested, and it must not be read as the server’s answer.

Source

pub fn build(self) -> Result<HttpsClient, ClientError>

Build the HttpsClient or return a configuration error.

Trait Implementations§

Source§

impl Default for HttpsClientBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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