diff --git a/webrtc/dtls/dtls.nim b/webrtc/dtls/dtls.nim index c984e67..9b467ae 100644 --- a/webrtc/dtls/dtls.nim +++ b/webrtc/dtls/dtls.nim @@ -139,9 +139,9 @@ proc start*(self: Dtls, conn: StunConn, laddr: TransportAddress) = mb_entropy_init(self.entropy) mb_ctr_drbg_seed(self.ctr_drbg, mbedtls_entropy_func, self.entropy, nil, 0) - var pkey = self.ctr_drbg.generateKey() - var srvcert = self.ctr_drbg.generateCertificate(pkey) - self.localCert = newSeq[byte](srvcert.raw.len) + self.serverPrivKey = self.ctr_drbg.generateKey() + self.serverCert = self.ctr_drbg.generateCertificate(self.serverPrivKey) + self.localCert = newSeq[byte](self.serverCert.raw.len) proc stop*(self: Dtls) = if not self.started: @@ -205,10 +205,10 @@ proc accept*(self: Dtls): Future[DtlsConn] {.async.} = res.ctr_drbg = self.ctr_drbg res.entropy = self.entropy - var pkey = res.ctr_drbg.generateKey() - var srvcert = res.ctr_drbg.generateCertificate(pkey) + var pkey = self.serverPrivKey + var srvcert = self.serverCert res.localCert = newSeq[byte](srvcert.raw.len) - copyMem(addr res.localCert[0], srvcert.raw.p, srvcert.raw.len) + res.localCert = self.localCert mb_ssl_config_defaults(res.config, MBEDTLS_SSL_IS_SERVER, diff --git a/webrtc/udp_connection.nim b/webrtc/udp_connection.nim index 6f66da7..adf2463 100644 --- a/webrtc/udp_connection.nim +++ b/webrtc/udp_connection.nim @@ -15,7 +15,7 @@ logScope: type UdpConn* = ref object - laddr: TransportAddress + laddr*: TransportAddress udp: DatagramTransport dataRecv: AsyncQueue[(seq[byte], TransportAddress)] diff --git a/webrtc/webrtc.nim b/webrtc/webrtc.nim index 1ce299a..1c39eb8 100644 --- a/webrtc/webrtc.nim +++ b/webrtc/webrtc.nim @@ -25,9 +25,6 @@ type sctp*: Sctp port: int -proc dtlsLocalCertificate(w: WebRTC): seq[byte] = - w.dtls.localCertificate() - proc new*(T: typedesc[WebRTC], address: TransportAddress): T = var webrtc = T(udp: UdpConn(), stun: StunConn(), dtls: Dtls()) webrtc.udp.init(address)