File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,31 @@ func (r *DTLSTransport) ICETransport() *ICETransport {
3434 underlying : underlying ,
3535 }
3636}
37+
38+ func (t * DTLSTransport ) GetRemoteCertificate () []byte {
39+ if t .underlying .IsNull () || t .underlying .IsUndefined () {
40+ return nil
41+ }
42+
43+ // Firefox does not support getRemoteCertificates: https://bugzilla.mozilla.org/show_bug.cgi?id=1805446
44+ jsGet := t .underlying .Get ("getRemoteCertificates" )
45+ if jsGet .IsUndefined () || jsGet .IsNull () {
46+ return nil
47+ }
48+
49+ jsCerts := t .underlying .Call ("getRemoteCertificates" )
50+ if jsCerts .Length () == 0 {
51+ return nil
52+ }
53+
54+ buf := jsCerts .Index (0 )
55+ u8 := js .Global ().Get ("Uint8Array" ).New (buf )
56+
57+ if u8 .Length () == 0 {
58+ return nil
59+ }
60+
61+ cert := make ([]byte , u8 .Length ())
62+ js .CopyBytesToGo (cert , u8 )
63+ return cert
64+ }
You can’t perform that action at this time.
0 commit comments