pub struct TlsConfig { /* private fields */ }Available on crate feature
server only.Expand description
Configuration to use for the TLS connection
This struct wraps a rustls server configuration and TLS acceptor for use with
RelayService::handle_connection.
§Example
use std::sync::Arc;
use iroh_relay::server::http_server::TlsConfig;
use rustls::ServerConfig;
use webpki_types::{CertificateDer, PrivateKeyDer};
// Generate a self-signed certificate for testing
let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_string()])?;
let cert_der = cert.cert.der().to_vec();
let private_key_der = cert.signing_key.serialize_der();
// Create rustls types
let cert_chain = vec![CertificateDer::from(cert_der)];
let private_key = PrivateKeyDer::try_from(private_key_der)?;
// Create a rustls ServerConfig
let server_config = Arc::new(
ServerConfig::builder()
.with_no_client_auth()
.with_single_cert(cert_chain, private_key)?,
);
// Create TlsConfig for use with RelayService
let tls_config = TlsConfig::new(server_config);Implementations§
Source§impl TlsConfig
impl TlsConfig
Sourcepub fn new(config: Arc<ServerConfig>) -> Self
pub fn new(config: Arc<ServerConfig>) -> Self
Creates a new TlsConfig from a rustls ServerConfig.
This creates a manual TLS acceptor using the provided server configuration. The acceptor will handle TLS handshakes for incoming connections.
§Example
use std::sync::Arc;
use iroh_relay::server::http_server::TlsConfig;
use rustls::ServerConfig;
use webpki_types::{CertificateDer, PrivateKeyDer};
// Generate a self-signed certificate for testing
let cert = rcgen::generate_simple_self_signed(vec!["localhost".to_string()])?;
let cert_der = cert.cert.der().to_vec();
let private_key_der = cert.signing_key.serialize_der();
// Create rustls types
let cert_chain = vec![CertificateDer::from(cert_der)];
let private_key = PrivateKeyDer::try_from(private_key_der)?;
let server_config = Arc::new(
ServerConfig::builder()
.with_no_client_auth()
.with_single_cert(cert_chain, private_key)?,
);
let tls_config = TlsConfig::new(server_config);Trait Implementations§
Auto Trait Implementations§
impl Freeze for TlsConfig
impl !RefUnwindSafe for TlsConfig
impl Send for TlsConfig
impl Sync for TlsConfig
impl Unpin for TlsConfig
impl !UnwindSafe for TlsConfig
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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