@@ -23,7 +23,7 @@ use rand::thread_rng;
2323use crate :: {
2424 buffer_pool:: { BufferHandle , BufferPool , OwnedBuffer } ,
2525 client:: { Client , ClientError , MessageType , MAX_UDP_PAYLOAD_SIZE } ,
26- crypto:: Crypto ,
26+ crypto:: SslConfig ,
2727 runtime:: { Runtime , UdpSocket } ,
2828 sdp:: { gen_sdp_response, parse_sdp_fields, SdpFields } ,
2929 stun:: { parse_stun_binding_request, write_stun_success_response} ,
@@ -123,12 +123,14 @@ pub struct SessionEndpoint {
123123
124124impl SessionEndpoint {
125125 /// Receives an incoming SDP descriptor of an `RTCSessionDescription` from a browser, informs
126- /// the corresponding `Server` of the new WebRTC session, and returns a JSON object containing
127- /// objects which can construct an `RTCSessionDescription` and an `RTCIceCandidate` in a
128- /// browser.
126+ /// the corresponding `Server` of the new WebRTC session, and returns a JSON object
127+ /// containing two fields:
128+ /// 1) An `answer` field which is an SDP descriptor that can be used to construct an
129+ /// `RTCSessionDescription`.
130+ /// 2) a `candidate` field which is a configuration object for an `RTCIceCandidate`.
129131 ///
130- /// The returned JSON object contains a digest of the x509 certificate the server will use for
131- /// DTLS, and the browser will ensure that this digest matches before starting a WebRTC
132+ /// The returned SDP descriptor contains a digest of the x509 certificate the server will use
133+ /// for DTLS, and the browser will ensure that this digest matches before starting a WebRTC
132134 /// connection.
133135 pub async fn session_request < I , E , S > (
134136 & mut self ,
@@ -224,20 +226,25 @@ impl<R: Runtime> Server<R> {
224226 listen_addr : SocketAddr ,
225227 public_addr : SocketAddr ,
226228 ) -> Result < Self , IoError > {
227- Server :: with_crypto (
229+ Server :: with_ssl_config (
228230 runtime,
229231 listen_addr,
230232 public_addr,
231- Crypto :: init ( ) . expect ( "WebRTC server could not initialize OpenSSL primitives" ) ,
233+ SslConfig :: create ( ) . expect ( "WebRTC server could not initialize OpenSSL primitives" ) ,
232234 )
233235 . await
234236 }
235237
236- pub async fn with_crypto (
238+ /// Start a new WebRTC data channel server with the given `SslConfig`.
239+ ///
240+ /// This can be used to share self-signed TLS certificates between different `Server` instances,
241+ /// which is important in certain browsers (Firefox) when connecting to multiple WebRTC
242+ /// endpoints from the same page.
243+ pub async fn with_ssl_config (
237244 runtime : R ,
238245 listen_addr : SocketAddr ,
239246 public_addr : SocketAddr ,
240- crypto : Crypto ,
247+ crypto : SslConfig ,
241248 ) -> Result < Self , IoError > {
242249 const SESSION_BUFFER_SIZE : usize = 8 ;
243250
0 commit comments