Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/divergences.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ rejects `setConfiguration()` calls that change the certificate set, and passes
the first configured certificate into libdatachannel's `rtc::Configuration` so
the generated DTLS fingerprint appears in local SDP.

Certificate generation supports object-form ECDSA P-256 and RSA SHA-256
algorithms. String-form WebCrypto `AlgorithmIdentifier` values are rejected.

libdatachannel accepts one certificate/key pair for a peer connection. The W3C
configuration dictionary allows a sequence of certificates, and WPT has a case
that expects all configured certificate fingerprints to appear in SDP. The
Expand Down
4 changes: 1 addition & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ export class RTCSctpTransport extends EventTarget {
}

export class RTCPeerConnection extends EventTarget {
static generateCertificate(
algorithm: string | RTCCertificateKeygenAlgorithm,
): Promise<RTCCertificate>;
static generateCertificate(algorithm: RTCCertificateKeygenAlgorithm): Promise<RTCCertificate>;
constructor(configuration?: RTCConfiguration);
readonly localDescription: RTCSessionDescription | null;
readonly currentLocalDescription: RTCSessionDescription | null;
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3369,6 +3369,7 @@ class RTCPeerConnection extends SimpleEventTarget {
});
this._connectionState = "closed";
this._iceConnectionState = "closed";
this._iceGatheringState = "new";
this._deferredIceEvents = [];
this._preparedLocalDescription = null;
this._nonstandardPreparedLocalDescriptionType = null;
Expand Down
16 changes: 16 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,22 @@ test("generateCertificate returns a native-backed RTCCertificate", async (t) =>
pc.close();
});

test("generateCertificate rejects string-form algorithms", async () => {
await assert.rejects(
RTCPeerConnection.generateCertificate("ECDSA"),
(error) => error.name === "NotSupportedError",
);
});

test("close resets iceGatheringState to new", () => {
const pc = new RTCPeerConnection();

pc._iceGatheringState = "complete";
pc.close();

assert.equal(pc.iceGatheringState, "new");
});

test("createDataChannel rejects duplicate negotiated ids until the channel closes", async (t) => {
const pc = new RTCPeerConnection();
t.after(() => closeAllAndWait(pc));
Expand Down
2 changes: 2 additions & 0 deletions test/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const certificatePromise: Promise<RTCCertificate> = RTCPeerConnection.generateCe
namedCurve: "P-256",
expires: 60000,
});
// @ts-expect-error string-form certificate algorithms are not supported.
RTCPeerConnection.generateCertificate("ECDSA");
const pc = new RTCPeerConnection();
pc.setConfiguration({ iceServers: [{ urls: "stun:stun.example.org" }], iceCandidatePoolSize: 0 });
const configuration = pc.getConfiguration();
Expand Down
Loading