pub struct ClientConfigBuilder { /* private fields */ }Expand description
Builds a rustls::ClientConfig backed by a live SPIFFE X509Source.
The resulting client configuration:
- presents the current SPIFFE X.509 SVID as the client certificate
- validates the server certificate chain against the trust domain bundle
- authorizes the server by SPIFFE ID (URI SAN)
The builder retains an Arc<X509Source>. When the underlying SVID or trust
bundle is rotated by the SPIRE agent, new TLS handshakes automatically use
the updated material.
§Authorization
Server authorization is performed by invoking the provided
AuthorizeSpiffeId hook with the server’s SPIFFE ID extracted from the
certificate’s URI SAN.
Use ClientConfigOptions::allow_any to disable authorization while
retaining full TLS authentication.
Implementations§
Source§impl ClientConfigBuilder
impl ClientConfigBuilder
Sourcepub fn new(source: Arc<X509Source>, opts: ClientConfigOptions) -> Self
pub fn new(source: Arc<X509Source>, opts: ClientConfigOptions) -> Self
Creates a new builder from an X509Source and options.
Sourcepub fn build(self) -> Result<ClientConfig>
pub fn build(self) -> Result<ClientConfig>
Builds the rustls::ClientConfig.
The returned configuration:
- presents the current SPIFFE X.509 SVID as the client certificate
- validates the server certificate chain against the configured trust domain
- authorizes the server by SPIFFE ID (URI SAN)
The configuration is backed by a live X509Source. When the underlying
SVID or trust bundle is rotated by the SPIRE agent, new TLS handshakes
automatically use the updated material.
§Errors
Returns an error if:
- the Rustls crypto provider is not installed
- no current X.509 SVID is available from the
X509Source - the trust bundle for the configured trust domain is missing
- building the underlying Rustls certificate verifier fails
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClientConfigBuilder
impl !RefUnwindSafe for ClientConfigBuilder
impl Send for ClientConfigBuilder
impl Sync for ClientConfigBuilder
impl Unpin for ClientConfigBuilder
impl !UnwindSafe for ClientConfigBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request