mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-02 19:57:35 +03:00
sync: 0.42.0 merge commit
Signed-off-by: Gaukas Wang <i@gaukas.wang>
This commit is contained in:
commit
b66e1ed5f5
2 changed files with 50 additions and 5 deletions
50
internal/qtls/cipher_suite_test.go
Normal file
50
internal/qtls/cipher_suite_test.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package qtls
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/quic-go/quic-go/internal/testdata"
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Setting the Cipher Suite", func() {
|
||||
for _, cs := range []uint16{tls.TLS_AES_128_GCM_SHA256, tls.TLS_CHACHA20_POLY1305_SHA256, tls.TLS_AES_256_GCM_SHA384} {
|
||||
cs := cs
|
||||
|
||||
It(fmt.Sprintf("selects %s", tls.CipherSuiteName(cs)), func() {
|
||||
reset := SetCipherSuite(cs)
|
||||
defer reset()
|
||||
|
||||
ln, err := tls.Listen("tcp4", "localhost:0", testdata.GetTLSConfig())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer ln.Close()
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
defer close(done)
|
||||
conn, err := ln.Accept()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = conn.Read(make([]byte, 10))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(conn.(*tls.Conn).ConnectionState().CipherSuite).To(Equal(cs))
|
||||
}()
|
||||
|
||||
conn, err := tls.Dial(
|
||||
"tcp4",
|
||||
fmt.Sprintf("localhost:%d", ln.Addr().(*net.TCPAddr).Port),
|
||||
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||
)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = conn.Write([]byte("foobar"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(conn.ConnectionState().CipherSuite).To(Equal(cs))
|
||||
Expect(conn.Close()).To(Succeed())
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
}
|
||||
})
|
|
@ -1,5 +0,0 @@
|
|||
//go:build !go1.20
|
||||
|
||||
package qtls
|
||||
|
||||
var _ int = "The version of quic-go you're using can't be built using outdated Go versions. For more details, please see https://github.com/refraction-networking/uquic/wiki/quic-go-and-Go-versions."
|
Loading…
Add table
Add a link
Reference in a new issue