pub struct TlsConfig { /* private fields */ }Expand description
Configuration for Spanner Omni TLS / mTLS transport security.
Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty TLS configuration.
§Example
let config = TlsConfig::new();
assert!(!config.has_custom_certificates());Sourcepub fn with_root_certificate_pem(
self,
root_certificate_pem: impl Into<Vec<u8>>,
) -> Self
pub fn with_root_certificate_pem( self, root_certificate_pem: impl Into<Vec<u8>>, ) -> Self
Configures a custom Root CA certificate in PEM format to verify the Omni server’s certificate.
§Example
let ca_pem = b"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----";
let config = TlsConfig::new().with_root_certificate_pem(ca_pem);Sourcepub fn with_client_certificate_pem(
self,
client_certificate_pem: impl Into<Vec<u8>>,
client_private_key_pem: impl Into<Vec<u8>>,
) -> Self
pub fn with_client_certificate_pem( self, client_certificate_pem: impl Into<Vec<u8>>, client_private_key_pem: impl Into<Vec<u8>>, ) -> Self
Configures client certificate and private key in PEM format for mutual TLS (mTLS) authentication.
§Example
let cert_pem = b"-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----";
let key_pem = b"-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----";
let config = TlsConfig::new().with_client_certificate_pem(cert_pem, key_pem);Sourcepub fn with_client_certificate_file(
self,
certificate_path: impl AsRef<Path>,
private_key_path: impl AsRef<Path>,
) -> Result<Self, TlsError>
pub fn with_client_certificate_file( self, certificate_path: impl AsRef<Path>, private_key_path: impl AsRef<Path>, ) -> Result<Self, TlsError>
Sourcepub fn with_domain_name_override(self, domain_name: impl Into<String>) -> Self
pub fn with_domain_name_override(self, domain_name: impl Into<String>) -> Self
Configures an explicit TLS domain name override (SNI / server name verification).
§Example
let config = TlsConfig::new().with_domain_name_override("spanner.internal");Sourcepub fn root_certificate(&self) -> Option<&[u8]>
pub fn root_certificate(&self) -> Option<&[u8]>
Returns the configured Root CA certificate bytes in PEM format, if any.
Sourcepub fn client_certificate(&self) -> Option<&[u8]>
pub fn client_certificate(&self) -> Option<&[u8]>
Returns the configured client certificate bytes in PEM format, if any.
Sourcepub fn client_private_key(&self) -> Option<&[u8]>
pub fn client_private_key(&self) -> Option<&[u8]>
Returns the configured client private key bytes in PEM format, if any.
Sourcepub fn domain_name_override(&self) -> Option<&str>
pub fn domain_name_override(&self) -> Option<&str>
Returns the configured TLS domain name override, if any.
Sourcepub fn has_custom_certificates(&self) -> bool
pub fn has_custom_certificates(&self) -> bool
Returns true if any custom root CA or client certificates are configured.
Sourcepub fn validate(&self) -> Result<(), TlsError>
pub fn validate(&self) -> Result<(), TlsError>
Validates that the TLS configuration is internally consistent.
§Errors
- Returns
TlsError::MissingClientKeyif a client certificate is set without a private key. - Returns
TlsError::MissingClientCertificateif a client private key is set without a certificate.
Trait Implementations§
impl Eq for TlsConfig
impl StructuralPartialEq for TlsConfig
Auto Trait Implementations§
impl Forget for TlsConfig
impl Freeze for TlsConfig
impl Move for TlsConfig
impl RefUnwindSafe for TlsConfig
impl Send for TlsConfig
impl Sync for TlsConfig
impl Unpin for TlsConfig
impl UnsafeUnpin for TlsConfig
impl UnwindSafe for TlsConfig
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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