diff --git a/cert/generate b/cert/generate index 5103f25..4376f56 100755 --- a/cert/generate +++ b/cert/generate @@ -17,6 +17,3 @@ mkcert -ecdsa -cert-file "$CRT" -key-file "$KEY" localhost 127.0.0.1 ::1 # Reduce the expiration time of the certificate to 14 days; the WebTransport maximum. # TODO https://github.com/FiloSottile/mkcert/pull/513 openssl x509 -days 14 -in "$CRT" -signkey "$KEY" -out "$CRT" - -# Compute the sha256 fingerprint of the certificate for WebTransport -# openssl x509 -in "$CRT" -outform der | openssl dgst -sha256 diff --git a/player/fingerprint.sha256 b/player/fingerprint.sha256 new file mode 100644 index 0000000..3545bf9 --- /dev/null +++ b/player/fingerprint.sha256 @@ -0,0 +1 @@ +50e151a79d06af6b9289180af319ca974e227d9ec58c30362c9304e56df3e3ea diff --git a/player/package.json b/player/package.json index 5ebb925..0c4f4be 100644 --- a/player/package.json +++ b/player/package.json @@ -6,9 +6,10 @@ "check": "tsc --noEmit" }, "devDependencies": { + "@parcel/transformer-inline-string": "2.8.3", "@parcel/validator-typescript": "^2.6.0", + "@types/dom-webcodecs": "^0.1.6", "parcel": "^2.8.0", - "typescript": ">=3.0.0", - "@types/dom-webcodecs": "^0.1.6" + "typescript": ">=3.0.0" } } diff --git a/player/src/transport/fingerprint.hex b/player/src/transport/fingerprint.hex new file mode 100644 index 0000000..8e821ec --- /dev/null +++ b/player/src/transport/fingerprint.hex @@ -0,0 +1 @@ +642ab03bc58c48ed614e6523d93c2455d8223aedfbdcba7f502ca0ea08590921 diff --git a/player/src/transport/index.ts b/player/src/transport/index.ts index e42da4e..6c45ac9 100644 --- a/player/src/transport/index.ts +++ b/player/src/transport/index.ts @@ -3,6 +3,7 @@ import * as Stream from "../stream" import * as MP4 from "../mp4" import Video from "../video/index" +import fingerprint from 'bundle-text:./fingerprint.hex'; /// @@ -43,29 +44,16 @@ export class Player { } async connect(url: string): Promise { - // TODO remove this when WebTransport supports the system CA pool - const fingerprintURL = new URL(url); - fingerprintURL.pathname = "/fingerprint" - - const response = await fetch(fingerprintURL) - if (!response.ok) { - throw new Error('failed to get server fingerprint'); - } - - const hex = await response.text() - // Convert the hex to binary. - let fingerprint = []; - for (let c = 0; c < hex.length; c += 2) { - fingerprint.push(parseInt(hex.substring(c, c+2), 16)); + let hash = []; + for (let c = 0; c < fingerprint.length; c += 2) { + hash.push(parseInt(fingerprint.substring(c, c+2), 16)); } - //const fingerprint = Uint8Array.from(atob(hex), c => c.charCodeAt(0)) - const quic = new WebTransport(url, { "serverCertificateHashes": [{ "algorithm": "sha-256", - "value": new Uint8Array(fingerprint), + "value": new Uint8Array(hash), }] }) diff --git a/player/src/video/renderer.ts b/player/src/video/renderer.ts index 0ec28f5..95c5cd0 100644 --- a/player/src/video/renderer.ts +++ b/player/src/video/renderer.ts @@ -60,8 +60,6 @@ export class Renderer { break } - console.log("dropping frame") - frame.close() this.queue.shift() diff --git a/player/yarn.lock b/player/yarn.lock index 056dc27..24f0b4e 100644 --- a/player/yarn.lock +++ b/player/yarn.lock @@ -576,6 +576,13 @@ "@parcel/workers" "2.8.3" nullthrows "^1.1.1" +"@parcel/transformer-inline-string@2.8.3": + version "2.8.3" + resolved "https://registry.yarnpkg.com/@parcel/transformer-inline-string/-/transformer-inline-string-2.8.3.tgz#693f13dd3d3f5f19c3af9389643328328496ace5" + integrity sha512-TBMk2H9nV8JMOsLztalhzS6HgthG5SCHKYkR2MaW7eSZuSGotbSP22aJip8HgQZ/lPMdOMb1lknHmd8WROxWHg== + dependencies: + "@parcel/plugin" "2.8.3" + "@parcel/transformer-js@2.8.3": version "2.8.3" resolved "https://registry.yarnpkg.com/@parcel/transformer-js/-/transformer-js-2.8.3.tgz#fe400df428394d1e7fe5afb6dea5c7c858e44f03" diff --git a/server/go.mod b/server/go.mod index 1b83d5f..7e5b4fb 100644 --- a/server/go.mod +++ b/server/go.mod @@ -20,7 +20,7 @@ require ( github.com/marten-seemann/qtls-go1-18 v0.1.3 // indirect github.com/marten-seemann/qtls-go1-19 v0.1.1 // indirect github.com/onsi/ginkgo/v2 v2.2.0 // indirect - golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect + golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect diff --git a/server/go.sum b/server/go.sum index a709198..fed92be 100644 --- a/server/go.sum +++ b/server/go.sum @@ -77,7 +77,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lucas-clemente/quic-go v0.31.0 h1:MfNp3fk0wjWRajw6quMFA3ap1AVtlU+2mtwmbVogB2M= github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/marten-seemann/qpack v0.3.0 h1:UiWstOgT8+znlkDPOg2+3rIuYXJ2CnGDkGUXN6ki6hE= @@ -153,8 +152,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 h1:/pEO3GD/ABYAjuakUS6xSEmmlyVS4kxBNkeA9tLJiTI= -golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o= +golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= diff --git a/server/internal/warp/warp.go b/server/internal/warp/server.go similarity index 100% rename from server/internal/warp/warp.go rename to server/internal/warp/server.go diff --git a/server/internal/warp/session.go b/server/internal/warp/session.go index d52c42f..a267619 100644 --- a/server/internal/warp/session.go +++ b/server/internal/warp/session.go @@ -176,6 +176,11 @@ func (s *Session) writeInit(ctx context.Context, init *MediaInit) (err error) { return fmt.Errorf("failed to create stream: %w", err) } + if temp == nil { + // Not sure when this happens, perhaps when closing a connection? + return fmt.Errorf("received a nil stream from quic-go") + } + // Wrap the stream in an object that buffers writes instead of blocking. stream := NewStream(temp) s.streams.Add(stream.Run) @@ -217,7 +222,7 @@ func (s *Session) writeSegment(ctx context.Context, segment *MediaSegment) (err if temp == nil { // Not sure when this happens, perhaps when closing a connection? - return fmt.Errorf("received a nil stream from quic-go: %w", err) + return fmt.Errorf("received a nil stream from quic-go") } // Wrap the stream in an object that buffers writes instead of blocking. diff --git a/server/main.go b/server/main.go index a0b5f9b..9689c89 100644 --- a/server/main.go +++ b/server/main.go @@ -56,6 +56,8 @@ func run(ctx context.Context) (err error) { hash := sha256.Sum256(tlsCert.Certificate[0]) fingerprint := hex.EncodeToString(hash[:]) + fmt.Println(fingerprint) + webConfig := web.Config{ Addr: *addr, CertFile: *cert,