mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
use a self-signed certificate for integration tests
This commit is contained in:
parent
7b880f259f
commit
4abcce6408
22 changed files with 225 additions and 159 deletions
|
@ -8,13 +8,11 @@ defaults: &defaults
|
||||||
go get -t ./...
|
go get -t ./...
|
||||||
go get github.com/onsi/ginkgo/ginkgo
|
go get github.com/onsi/ginkgo/ginkgo
|
||||||
go get github.com/onsi/gomega
|
go get github.com/onsi/gomega
|
||||||
echo 127.0.0.1 quic.clemente.io | sudo tee -a /etc/hosts
|
|
||||||
- run:
|
- run:
|
||||||
name: "Build infos"
|
name: "Build infos"
|
||||||
command: |
|
command: |
|
||||||
echo $GOARCH
|
echo $GOARCH
|
||||||
go version
|
go version
|
||||||
printf "quic.clemente.io certificate valid until: " && openssl x509 -in example/fullchain.pem -enddate -noout | cut -d = -f 2
|
|
||||||
- run:
|
- run:
|
||||||
name: "Run benchmark tests"
|
name: "Run benchmark tests"
|
||||||
command: ginkgo -randomizeAllSpecs -trace benchmark -- -samples=1
|
command: ginkgo -randomizeAllSpecs -trace benchmark -- -samples=1
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
dist: trusty
|
dist: trusty
|
||||||
group: travis_latest
|
group: travis_latest
|
||||||
|
|
||||||
addons:
|
|
||||||
hosts:
|
|
||||||
- quic.clemente.io
|
|
||||||
|
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
|
@ -41,7 +37,6 @@ before_install:
|
||||||
- go get github.com/onsi/gomega
|
- go get github.com/onsi/gomega
|
||||||
- export GOARCH=$TRAVIS_GOARCH
|
- export GOARCH=$TRAVIS_GOARCH
|
||||||
- go env # for debugging
|
- go env # for debugging
|
||||||
- "printf \"quic.clemente.io certificate valid until: \" && openssl x509 -in example/fullchain.pem -enddate -noout | cut -d = -f 2"
|
|
||||||
- "export DISPLAY=:99.0"
|
- "export DISPLAY=:99.0"
|
||||||
- "Xvfb $DISPLAY &> /dev/null &"
|
- "Xvfb $DISPLAY &> /dev/null &"
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,6 @@ environment:
|
||||||
- GOARCH: 386
|
- GOARCH: 386
|
||||||
- GOARCH: amd64
|
- GOARCH: amd64
|
||||||
|
|
||||||
hosts:
|
|
||||||
quic.clemente.io: 127.0.0.1
|
|
||||||
|
|
||||||
clone_folder: c:\gopath\src\github.com\lucas-clemente\quic-go
|
clone_folder: c:\gopath\src\github.com\lucas-clemente\quic-go
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# About the certificate
|
|
||||||
|
|
||||||
Yes, this folder contains a private key and a certificate for quic.clemente.io.
|
|
||||||
|
|
||||||
Unfortunately we need a valid certificate for the integration tests with Chrome and `quic_client`. No important data is served on the "real" `quic.clemente.io` (only a test page), and the MITM problem is imho negligible.
|
|
||||||
|
|
||||||
If you figure out a way to test with Chrome without having a cert and key here, let us now in an issue.
|
|
|
@ -1,62 +0,0 @@
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIGDDCCBPSgAwIBAgISAzFzQHPYT5Vnbq8NLMKNdHANMA0GCSqGSIb3DQEBCwUA
|
|
||||||
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
|
|
||||||
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xODA5MDgwODIwMTFaFw0x
|
|
||||||
ODEyMDcwODIwMTFaMBsxGTAXBgNVBAMTEHF1aWMuY2xlbWVudGUuaW8wggEiMA0G
|
|
||||||
CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC54rxI2G99GLs7VKnIbKnl+FjQxjj5
|
|
||||||
6e01dW6mE+3JSouBG3K+9hO6dExvZS4zUqL0hxi93H480WGtIn8bIYVpcZZvkgzG
|
|
||||||
i8ot3Hq2SXOBb3nBTCj7Y+DB4oJX1rPNqn0YVS8LidxUKIhsFOgIpj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BBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHYA23Sv7ssp7LH+yj5xbSzluaq7
|
|
||||||
NveEcYPHXZ1PN7Yfv2QAAAFluHtHHAAABAMARzBFAiEAk+yUopdJ1uIGOsCMLEof
|
|
||||||
qBYJKCq1qU6lEd4DSmh5Q8UCIDPgjfWG6JRJLtNrVCcayQpLgNlFDx1Mx/lWkpOb
|
|
||||||
VuigAHcAKTxRllTIOWW6qlD8WAfUt2+/WHopctykwwz05UVH9HgAAAFluHtIDAAA
|
|
||||||
BAMASDBGAiEAvgKW8+NpBYBYPSglVaQZ/GZww/QItzpsVj305GoB87cCIQDEDbjH
|
|
||||||
feFKJo/7C20pOha1lERVZae6XLlRZVL+UMP8+jANBgkqhkiG9w0BAQsFAAOCAQEA
|
|
||||||
eZuO6bQsmBu2iQVxOdSmRtu/VXsYZi+fyteToSNtexWYu6SAUfe5dr5MHD2m3OeU
|
|
||||||
oYIxHeKtSMjiE7o7BVUUZgVaCXjjT/nR1iyJvVxAt9ekd4lcjjoudoxQHms76KU9
|
|
||||||
dcEr8M/z4/PhuB83nvpJB40mgJln47BhvKKAeFtfD+c+gR4L5NG0LC6H7Jbc8PyR
|
|
||||||
WPEzc1HCfHaHkkVgLRljgky8hl83+uR95lgjSPKYyRy8qCwL/1mthdaGpfP6u+aD
|
|
||||||
9tsDjMFEj+Lq7RDeiZkBoZ6uZnqjFcfg4sLlwuv/aFvbAbkPa25SpwizdKRLFVNr
|
|
||||||
WtT2VbhFhz86rXplNgnJEw==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
|
|
||||||
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
|
||||||
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMD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sLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
|
|
||||||
Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
|
|
||||||
AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
|
|
||||||
uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
|
|
||||||
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
|
|
||||||
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
|
|
||||||
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
|
|
||||||
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
|
|
||||||
-----END CERTIFICATE-----
|
|
|
@ -1,28 +0,0 @@
|
||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC54rxI2G99GLs7
|
|
||||||
VKnIbKnl+FjQxjj56e01dW6mE+3JSouBG3K+9hO6dExvZS4zUqL0hxi93H480WGt
|
|
||||||
In8bIYVpcZZvkgzGi8ot3Hq2SXOBb3nBTCj7Y+DB4oJX1rPNqn0YVS8LidxUKIhs
|
|
||||||
FOgIpjrhXsa1ugI3ia5djPLxQYUc1r/48flUjTYy9HDD+VFUINPtVJzXJz3/7liP
|
|
||||||
dgbhSy4Uzpe5cu4ckgNTikQ6CuxGf3+8y9BP2nNOKe1nI3ubfC+gj4oUbOaoYA/t
|
|
||||||
VTcJxJimy+/mI9sx/Ku9lxzC/DdZwv7PRM3Q0BsE3/2I7DRRMENJof4zQfe/XvD9
|
|
||||||
WZ09+AdjAgMBAAECggEAL3O8EPR/cXXQxhK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+tlcBa1EKWHBFDfjWjiR/bOzoqFO1ROMD83BJGvROot
|
|
||||||
L1tBH2aVKAknBiBrDBXHlXVtctE5quNMs8iZa3cJAoGBAMX3qTxgsfCfWemJjj35
|
|
||||||
PJnzMRTe0gKQbeVw7tkp57G8vz1b+fblaDBCI63tj0O0PZ5nE01Y882g9NRNBI04
|
|
||||||
LYquJcRy8Mhb0R0EmoX1CAXTJPsZCmd3/rPLAUXser4zK6Yy/dkJFcD8NOMNWcX+
|
|
||||||
ok6Vq4VGdKA7ZxzJrKm3DGt/
|
|
||||||
-----END PRIVATE KEY-----
|
|
|
@ -2,17 +2,17 @@ package self_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
quic "github.com/lucas-clemente/quic-go"
|
quic "github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/h2quic"
|
"github.com/lucas-clemente/quic-go/h2quic"
|
||||||
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
"github.com/lucas-clemente/quic-go/integrationtests/tools/testserver"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/testdata"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
@ -25,13 +25,6 @@ var _ = Describe("Client tests", func() {
|
||||||
versions := protocol.SupportedVersions
|
versions := protocol.SupportedVersions
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
err := os.Setenv("HOSTALIASES", "quic.clemente.io 127.0.0.1")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
addr, err := net.ResolveUDPAddr("udp4", "quic.clemente.io:0")
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
if addr.String() != "127.0.0.1:0" {
|
|
||||||
Fail("quic.clemente.io does not resolve to 127.0.0.1. Consider adding it to /etc/hosts.")
|
|
||||||
}
|
|
||||||
testserver.StartQuicServer(versions)
|
testserver.StartQuicServer(versions)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -46,6 +39,9 @@ var _ = Describe("Client tests", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
client = &http.Client{
|
client = &http.Client{
|
||||||
Transport: &h2quic.RoundTripper{
|
Transport: &h2quic.RoundTripper{
|
||||||
|
TLSClientConfig: &tls.Config{
|
||||||
|
RootCAs: testdata.GetRootCA(),
|
||||||
|
},
|
||||||
QuicConfig: &quic.Config{
|
QuicConfig: &quic.Config{
|
||||||
Versions: []protocol.VersionNumber{version},
|
Versions: []protocol.VersionNumber{version},
|
||||||
},
|
},
|
||||||
|
@ -54,7 +50,7 @@ var _ = Describe("Client tests", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("downloads a hello", func() {
|
It("downloads a hello", func() {
|
||||||
resp, err := client.Get("https://quic.clemente.io:" + testserver.Port() + "/hello")
|
resp, err := client.Get("https://localhost:" + testserver.Port() + "/hello")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(resp.StatusCode).To(Equal(200))
|
Expect(resp.StatusCode).To(Equal(200))
|
||||||
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 3*time.Second))
|
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 3*time.Second))
|
||||||
|
@ -63,7 +59,7 @@ var _ = Describe("Client tests", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("downloads a small file", func() {
|
It("downloads a small file", func() {
|
||||||
resp, err := client.Get("https://quic.clemente.io:" + testserver.Port() + "/prdata")
|
resp, err := client.Get("https://localhost:" + testserver.Port() + "/prdata")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(resp.StatusCode).To(Equal(200))
|
Expect(resp.StatusCode).To(Equal(200))
|
||||||
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 5*time.Second))
|
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 5*time.Second))
|
||||||
|
@ -72,7 +68,7 @@ var _ = Describe("Client tests", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("downloads a large file", func() {
|
It("downloads a large file", func() {
|
||||||
resp, err := client.Get("https://quic.clemente.io:" + testserver.Port() + "/prdatalong")
|
resp, err := client.Get("https://localhost:" + testserver.Port() + "/prdatalong")
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(resp.StatusCode).To(Equal(200))
|
Expect(resp.StatusCode).To(Equal(200))
|
||||||
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 20*time.Second))
|
body, err := ioutil.ReadAll(gbytes.TimeoutReader(resp.Body, 20*time.Second))
|
||||||
|
@ -82,7 +78,7 @@ var _ = Describe("Client tests", func() {
|
||||||
|
|
||||||
It("uploads a file", func() {
|
It("uploads a file", func() {
|
||||||
resp, err := client.Post(
|
resp, err := client.Post(
|
||||||
"https://quic.clemente.io:"+testserver.Port()+"/echo",
|
"https://localhost:"+testserver.Port()+"/echo",
|
||||||
"text/plain",
|
"text/plain",
|
||||||
bytes.NewReader(testserver.PRData),
|
bytes.NewReader(testserver.PRData),
|
||||||
)
|
)
|
||||||
|
|
|
@ -47,8 +47,8 @@ var _ = Describe("Connection ID lengths tests", func() {
|
||||||
runClient := func(addr net.Addr, conf *quic.Config) {
|
runClient := func(addr net.Addr, conf *quic.Config) {
|
||||||
GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the client\n", conf.ConnectionIDLength)))
|
GinkgoWriter.Write([]byte(fmt.Sprintf("Using %d byte connection ID for the client\n", conf.ConnectionIDLength)))
|
||||||
cl, err := quic.DialAddr(
|
cl, err := quic.DialAddr(
|
||||||
fmt.Sprintf("quic.clemente.io:%d", addr.(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
|
||||||
&tls.Config{InsecureSkipVerify: true},
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
conf,
|
conf,
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package self_test
|
package self_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
mrand "math/rand"
|
mrand "math/rand"
|
||||||
"net"
|
"net"
|
||||||
|
@ -70,8 +71,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverSessionChan <- sess
|
serverSessionChan <- sess
|
||||||
}()
|
}()
|
||||||
sess, err := quic.DialAddr(
|
sess, err := quic.DialAddr(
|
||||||
fmt.Sprintf("quic.clemente.io:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
nil,
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
@ -102,8 +103,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverSessionChan <- sess
|
serverSessionChan <- sess
|
||||||
}()
|
}()
|
||||||
sess, err := quic.DialAddr(
|
sess, err := quic.DialAddr(
|
||||||
fmt.Sprintf("quic.clemente.io:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
nil,
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
@ -132,8 +133,8 @@ var _ = Describe("Handshake drop tests", func() {
|
||||||
serverSessionChan <- sess
|
serverSessionChan <- sess
|
||||||
}()
|
}()
|
||||||
sess, err := quic.DialAddr(
|
sess, err := quic.DialAddr(
|
||||||
fmt.Sprintf("quic.clemente.io:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
nil,
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -95,7 +95,7 @@ var _ = Describe("Handshake RTT tests", func() {
|
||||||
clientConfig = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}}
|
clientConfig = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}}
|
||||||
clientTLSConfig = &tls.Config{
|
clientTLSConfig = &tls.Config{
|
||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
ServerName: "quic.clemente.io",
|
ServerName: "localhost",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,14 @@ var _ = Describe("Handshake tests", func() {
|
||||||
version := v
|
version := v
|
||||||
|
|
||||||
Context(fmt.Sprintf("using %s", version), func() {
|
Context(fmt.Sprintf("using %s", version), func() {
|
||||||
var clientConfig *quic.Config
|
var (
|
||||||
|
tlsConf *tls.Config
|
||||||
|
clientConfig *quic.Config
|
||||||
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
serverConfig.Versions = []protocol.VersionNumber{version}
|
serverConfig.Versions = []protocol.VersionNumber{version}
|
||||||
|
tlsConf = &tls.Config{RootCAs: testdata.GetRootCA()}
|
||||||
clientConfig = &quic.Config{
|
clientConfig = &quic.Config{
|
||||||
Versions: []protocol.VersionNumber{version},
|
Versions: []protocol.VersionNumber{version},
|
||||||
}
|
}
|
||||||
|
@ -108,20 +112,32 @@ var _ = Describe("Handshake tests", func() {
|
||||||
|
|
||||||
It("accepts the certificate", func() {
|
It("accepts the certificate", func() {
|
||||||
runServer()
|
runServer()
|
||||||
_, err := quic.DialAddr(fmt.Sprintf("quic.clemente.io:%d", server.Addr().(*net.UDPAddr).Port), nil, clientConfig)
|
_, err := quic.DialAddr(
|
||||||
|
fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
|
tlsConf,
|
||||||
|
clientConfig,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("errors if the server name doesn't match", func() {
|
It("errors if the server name doesn't match", func() {
|
||||||
runServer()
|
runServer()
|
||||||
_, err := quic.DialAddr(fmt.Sprintf("127.0.0.1:%d", server.Addr().(*net.UDPAddr).Port), nil, clientConfig)
|
_, err := quic.DialAddr(
|
||||||
|
fmt.Sprintf("127.0.0.1:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
|
tlsConf,
|
||||||
|
clientConfig,
|
||||||
|
)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("uses the ServerName in the tls.Config", func() {
|
It("uses the ServerName in the tls.Config", func() {
|
||||||
runServer()
|
runServer()
|
||||||
conf := &tls.Config{ServerName: "quic.clemente.io"}
|
tlsConf.ServerName = "localhost"
|
||||||
_, err := quic.DialAddr(fmt.Sprintf("127.0.0.1:%d", server.Addr().(*net.UDPAddr).Port), conf, clientConfig)
|
_, err := quic.DialAddr(
|
||||||
|
fmt.Sprintf("127.0.0.1:%d", server.Addr().(*net.UDPAddr).Port),
|
||||||
|
tlsConf,
|
||||||
|
clientConfig,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package self_test
|
package self_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -46,8 +47,8 @@ var _ = Describe("Multiplexing", func() {
|
||||||
sess, err := quic.Dial(
|
sess, err := quic.Dial(
|
||||||
conn,
|
conn,
|
||||||
addr,
|
addr,
|
||||||
fmt.Sprintf("quic.clemente.io:%d", addr.(*net.UDPAddr).Port),
|
fmt.Sprintf("localhost:%d", addr.(*net.UDPAddr).Port),
|
||||||
nil,
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package self
|
package self
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -63,8 +64,8 @@ var _ = Describe("non-zero RTT", func() {
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
|
|
||||||
sess, err := quic.DialAddr(
|
sess, err := quic.DialAddr(
|
||||||
fmt.Sprintf("quic.clemente.io:%d", proxy.LocalPort()),
|
fmt.Sprintf("localhost:%d", proxy.LocalPort()),
|
||||||
nil,
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
&quic.Config{Versions: []protocol.VersionNumber{version}},
|
||||||
)
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package self_test
|
package self_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -36,7 +37,7 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
}
|
}
|
||||||
server, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), qconf)
|
server, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), qconf)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
serverAddr = fmt.Sprintf("quic.clemente.io:%d", server.Addr().(*net.UDPAddr).Port)
|
serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
@ -98,7 +99,11 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
runReceivingPeer(sess)
|
runReceivingPeer(sess)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runSendingPeer(client)
|
runSendingPeer(client)
|
||||||
})
|
})
|
||||||
|
@ -112,7 +117,11 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
sess.Close()
|
sess.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runReceivingPeer(client)
|
runReceivingPeer(client)
|
||||||
Eventually(client.Context().Done()).Should(BeClosed())
|
Eventually(client.Context().Done()).Should(BeClosed())
|
||||||
|
@ -135,7 +144,11 @@ var _ = Describe("Bidirectional streams", func() {
|
||||||
close(done1)
|
close(done1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
done2 := make(chan struct{})
|
done2 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package self_test
|
package self_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
@ -29,7 +30,7 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
qconf = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}}
|
qconf = &quic.Config{Versions: []protocol.VersionNumber{protocol.VersionTLS}}
|
||||||
server, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), qconf)
|
server, err = quic.ListenAddr("localhost:0", testdata.GetTLSConfig(), qconf)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
serverAddr = fmt.Sprintf("quic.clemente.io:%d", server.Addr().(*net.UDPAddr).Port)
|
serverAddr = fmt.Sprintf("localhost:%d", server.Addr().(*net.UDPAddr).Port)
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
@ -71,17 +72,19 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
It(fmt.Sprintf("client opening %d streams to a server", numStreams), func() {
|
It(fmt.Sprintf("client opening %d streams to a server", numStreams), func() {
|
||||||
var sess quic.Session
|
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
var err error
|
sess, err := server.Accept()
|
||||||
sess, err = server.Accept()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runReceivingPeer(sess)
|
runReceivingPeer(sess)
|
||||||
sess.Close()
|
sess.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runSendingPeer(client)
|
runSendingPeer(client)
|
||||||
<-client.Context().Done()
|
<-client.Context().Done()
|
||||||
|
@ -95,7 +98,11 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
runSendingPeer(sess)
|
runSendingPeer(sess)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
runReceivingPeer(client)
|
runReceivingPeer(client)
|
||||||
})
|
})
|
||||||
|
@ -117,7 +124,11 @@ var _ = Describe("Unidirectional Streams", func() {
|
||||||
close(done1)
|
close(done1)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
client, err := quic.DialAddr(serverAddr, nil, qconf)
|
client, err := quic.DialAddr(
|
||||||
|
serverAddr,
|
||||||
|
&tls.Config{RootCAs: testdata.GetRootCA()},
|
||||||
|
qconf,
|
||||||
|
)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
done2 := make(chan struct{})
|
done2 := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
|
|
|
@ -48,6 +48,8 @@ func (s *stream) Write(b []byte) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = Describe("Crypto Setup TLS", func() {
|
var _ = Describe("Crypto Setup TLS", func() {
|
||||||
|
var clientConf *tls.Config
|
||||||
|
|
||||||
initStreams := func() (chan chunk, *stream /* initial */, *stream /* handshake */) {
|
initStreams := func() (chan chunk, *stream /* initial */, *stream /* handshake */) {
|
||||||
chunkChan := make(chan chunk, 100)
|
chunkChan := make(chan chunk, 100)
|
||||||
initialStream := newStream(chunkChan, protocol.EncryptionInitial)
|
initialStream := newStream(chunkChan, protocol.EncryptionInitial)
|
||||||
|
@ -55,6 +57,13 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
return chunkChan, initialStream, handshakeStream
|
return chunkChan, initialStream, handshakeStream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BeforeEach(func() {
|
||||||
|
clientConf = &tls.Config{
|
||||||
|
ServerName: "localhost",
|
||||||
|
RootCAs: testdata.GetRootCA(),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
It("returns Handshake() when an error occurs", func() {
|
It("returns Handshake() when an error occurs", func() {
|
||||||
_, sInitialStream, sHandshakeStream := initStreams()
|
_, sInitialStream, sHandshakeStream := initStreams()
|
||||||
server, err := NewCryptoSetupServer(
|
server, err := NewCryptoSetupServer(
|
||||||
|
@ -231,7 +240,6 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
It("handshakes", func() {
|
It("handshakes", func() {
|
||||||
clientConf := &tls.Config{ServerName: "quic.clemente.io"}
|
|
||||||
serverConf := testdata.GetTLSConfig()
|
serverConf := testdata.GetTLSConfig()
|
||||||
clientErr, serverErr := handshakeWithTLSConf(clientConf, serverConf)
|
clientErr, serverErr := handshakeWithTLSConf(clientConf, serverConf)
|
||||||
Expect(clientErr).ToNot(HaveOccurred())
|
Expect(clientErr).ToNot(HaveOccurred())
|
||||||
|
@ -239,10 +247,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("handshakes with client auth", func() {
|
It("handshakes with client auth", func() {
|
||||||
clientConf := &tls.Config{
|
clientConf.Certificates = []tls.Certificate{generateCert()}
|
||||||
ServerName: "quic.clemente.io",
|
|
||||||
Certificates: []tls.Certificate{generateCert()},
|
|
||||||
}
|
|
||||||
serverConf := testdata.GetTLSConfig()
|
serverConf := testdata.GetTLSConfig()
|
||||||
serverConf.ClientAuth = qtls.RequireAnyClientCert
|
serverConf.ClientAuth = qtls.RequireAnyClientCert
|
||||||
clientErr, serverErr := handshakeWithTLSConf(clientConf, serverConf)
|
clientErr, serverErr := handshakeWithTLSConf(clientConf, serverConf)
|
||||||
|
@ -299,7 +304,7 @@ var _ = Describe("Crypto Setup TLS", func() {
|
||||||
protocol.ConnectionID{},
|
protocol.ConnectionID{},
|
||||||
cTransportParameters,
|
cTransportParameters,
|
||||||
func(p *TransportParameters) { sTransportParametersRcvd = p },
|
func(p *TransportParameters) { sTransportParametersRcvd = p },
|
||||||
&tls.Config{ServerName: "quic.clemente.io"},
|
clientConf,
|
||||||
protocol.VersionTLS,
|
protocol.VersionTLS,
|
||||||
[]protocol.VersionNumber{protocol.VersionTLS},
|
[]protocol.VersionNumber{protocol.VersionTLS},
|
||||||
protocol.VersionTLS,
|
protocol.VersionTLS,
|
||||||
|
|
18
internal/testdata/ca.pem
vendored
Normal file
18
internal/testdata/ca.pem
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIC0DCCAbgCCQCmiwJpSoekpDANBgkqhkiG9w0BAQsFADAqMRMwEQYDVQQKDApx
|
||||||
|
dWljLWdvIENBMRMwEQYDVQQLDApxdWljLWdvIENBMB4XDTE4MTIwODA2NDIyMVoX
|
||||||
|
DTI4MTIwNTA2NDIyMVowKjETMBEGA1UECgwKcXVpYy1nbyBDQTETMBEGA1UECwwK
|
||||||
|
cXVpYy1nbyBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN5MxI09
|
||||||
|
i01xRON732BFIuxO2SGjA9jYkvUvNXK886gifp2BfWLcOW1DHkXxBnhWMqfpcIWM
|
||||||
|
GviF4G2Mp0HEJDMe+4LBxje/1e2WA+nzQlIZD6LaDi98nXJaAcCMM4a64Vm0i8Z3
|
||||||
|
+4c+O93+5TekPn507nl7QA1IaEEtoek7w7wDw4ZF3ET+nns2HwVpV/ugfuYOQbTJ
|
||||||
|
8Np+zO8EfPMTUjEpKdl4bp/yqcouWD+oIhoxmx1V+LxshcpSwtzHIAi6gjHUDCEe
|
||||||
|
bk5Y2GBT4VR5WKmNGvlfe9L0Gn0ZLJoeXDshrunF0xEmSv8MxlHcKH/u4IHiO+6x
|
||||||
|
+5sdslqY7uEPEhkCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAhvXUMiatkgsnoRHc
|
||||||
|
UobKraGttETivxvtKpc48o1TSkR+kCKbMnygmrvc5niEqc9iDg8JI6HjBKJ3/hfA
|
||||||
|
uKdyiR8cQNcQRgJ/3FVx0n3KGDUbHJSuIQzFvXom2ZPdlAHFqAT+8AVrz42v8gct
|
||||||
|
gyiGdFCSNisDbevOiRHuJtZ0m8YsGgtfU48wqGOaSSsRz4mYD6kqBFd0+Ja3/EGv
|
||||||
|
vl24L5xMCy1zGGl6wKPa7TT7ok4TfD1YmIXOfmWYop6cTLwePLj1nHrLi0AlsSn1
|
||||||
|
2pFlosc9/qEbO5drqNoxUZfeF0L9RUSuArHRSO779dW/AmOtFdK3yaBGqflg0r7p
|
||||||
|
lYombA==
|
||||||
|
-----END CERTIFICATE-----
|
30
internal/testdata/cert.go
vendored
30
internal/testdata/cert.go
vendored
|
@ -2,6 +2,9 @@ package testdata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/pem"
|
||||||
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
@ -14,13 +17,12 @@ func init() {
|
||||||
panic("Failed to get current frame")
|
panic("Failed to get current frame")
|
||||||
}
|
}
|
||||||
|
|
||||||
certPath = path.Join(path.Dir(path.Dir(path.Dir(filename))), "example")
|
certPath = path.Dir(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCertificatePaths returns the paths to 'fullchain.pem' and 'privkey.pem' for the
|
// GetCertificatePaths returns the paths to certificate and key
|
||||||
// quic.clemente.io cert.
|
|
||||||
func GetCertificatePaths() (string, string) {
|
func GetCertificatePaths() (string, string) {
|
||||||
return path.Join(certPath, "fullchain.pem"), path.Join(certPath, "privkey.pem")
|
return path.Join(certPath, "cert.pem"), path.Join(certPath, "priv.key")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTLSConfig returns a tls config for quic.clemente.io
|
// GetTLSConfig returns a tls config for quic.clemente.io
|
||||||
|
@ -33,3 +35,23 @@ func GetTLSConfig() *tls.Config {
|
||||||
Certificates: []tls.Certificate{cert},
|
Certificates: []tls.Certificate{cert},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRootCA returns an x509.CertPool containing the CA certificate
|
||||||
|
func GetRootCA() *x509.CertPool {
|
||||||
|
caCertPath := path.Join(certPath, "ca.pem")
|
||||||
|
caCertRaw, err := ioutil.ReadFile(caCertPath)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
p, _ := pem.Decode(caCertRaw)
|
||||||
|
if p.Type != "CERTIFICATE" {
|
||||||
|
panic("expected a certificate")
|
||||||
|
}
|
||||||
|
caCert, err := x509.ParseCertificate(p.Bytes)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
certPool := x509.NewCertPool()
|
||||||
|
certPool.AddCert(caCert)
|
||||||
|
return certPool
|
||||||
|
}
|
||||||
|
|
18
internal/testdata/cert.pem
vendored
Normal file
18
internal/testdata/cert.pem
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIC3jCCAcYCCQCV4BOv+SRo4zANBgkqhkiG9w0BAQUFADAqMRMwEQYDVQQKDApx
|
||||||
|
dWljLWdvIENBMRMwEQYDVQQLDApxdWljLWdvIENBMB4XDTE4MTIwODA2NDMwMloX
|
||||||
|
DTI4MTIwNTA2NDMwMlowODEQMA4GA1UECgwHcXVpYy1nbzEQMA4GA1UECwwHcXVp
|
||||||
|
Yy1nbzESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
|
||||||
|
MIIBCgKCAQEAyc/hS8XHkOJaLrdPOSTZFUBVyHNSfQUX/3dEpmccPlLQLgopYZZO
|
||||||
|
W/cVhkxAfQ3e68xKkuZKfZN5Hytn5V/AOSk281BqxFxpfCcKVYqVpDZH99+jaVfG
|
||||||
|
ImPp5Y22qCnbSEwYrMTcLiK8PVa4MkpKf1KNacVlqawU+ZWI5fevAFGTtmrMJ4S+
|
||||||
|
qZY7tAaVkax+OiKWWfhLQjJCsN3IIDysTfbWao6cYKgtTfqVChEddzS7LRJVRaB+
|
||||||
|
+huUbB87tRBJbCuJX65yB7Fw77YiKoFjc5r2845fcS2Ew4+w29mbXoj7M7g6eup5
|
||||||
|
SnCydsCvyNy6VkgaSlWS0DXvxuzWshwUrwIDAQABMA0GCSqGSIb3DQEBBQUAA4IB
|
||||||
|
AQBWgmFunf44X3/NIjNvVLeQsfGW+4L/lCi2F5tqa70Hkda+xhKACnQQGB2qCSCF
|
||||||
|
Jfxj4iKrFJ7+JB8GnribWthLuDq49PQrTI+1wKFd9c2b8DXzJLz4Onw+mPX97pZm
|
||||||
|
TflQSIxXRaFAIQuUWNTArZZEe1ESSlnaBuE5w77LMf4GMFD3P3jzSHKUyM1sF97j
|
||||||
|
gRbIt8Jw7Uyd8vlXk6m2wvO5H3hZrrhJUJH3WW13a7wLJRnff2meKU90hkLQwuxO
|
||||||
|
kyh0k/h158/r2ibiahTmQEgHs9vQaCM+HXuk5P+Tzq5Zl/n0dMFZMfkqNkD4nym/
|
||||||
|
nu7zfdwMlcBjKt9g3BGw+KE3
|
||||||
|
-----END CERTIFICATE-----
|
31
internal/testdata/cert_test.go
vendored
Normal file
31
internal/testdata/cert_test.go
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package testdata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("certificates", func() {
|
||||||
|
It("returns certificates", func() {
|
||||||
|
ln, err := tls.Listen("tcp", "localhost:4433", GetTLSConfig())
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer GinkgoRecover()
|
||||||
|
conn, err := ln.Accept()
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer conn.Close()
|
||||||
|
_, err = conn.Write([]byte("foobar"))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
}()
|
||||||
|
|
||||||
|
conn, err := tls.Dial("tcp", "localhost:4433", &tls.Config{RootCAs: GetRootCA()})
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
data, err := ioutil.ReadAll(conn)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(string(data)).To(Equal("foobar"))
|
||||||
|
})
|
||||||
|
})
|
27
internal/testdata/priv.key
vendored
Normal file
27
internal/testdata/priv.key
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEogIBAAKCAQEAyc/hS8XHkOJaLrdPOSTZFUBVyHNSfQUX/3dEpmccPlLQLgop
|
||||||
|
YZZOW/cVhkxAfQ3e68xKkuZKfZN5Hytn5V/AOSk281BqxFxpfCcKVYqVpDZH99+j
|
||||||
|
aVfGImPp5Y22qCnbSEwYrMTcLiK8PVa4MkpKf1KNacVlqawU+ZWI5fevAFGTtmrM
|
||||||
|
J4S+qZY7tAaVkax+OiKWWfhLQjJCsN3IIDysTfbWao6cYKgtTfqVChEddzS7LRJV
|
||||||
|
RaB++huUbB87tRBJbCuJX65yB7Fw77YiKoFjc5r2845fcS2Ew4+w29mbXoj7M7g6
|
||||||
|
eup5SnCydsCvyNy6VkgaSlWS0DXvxuzWshwUrwIDAQABAoIBADunQwVO1Qqync2p
|
||||||
|
SbWueqyZc8HotL1XwBw3eQdm+yZA/GBfiJPcBhWRF7+20mkkrHwuyuxZPjOYX/ki
|
||||||
|
r3dRslQzJpcNckHQvy1/rMJUUJ9VnDhc1sTQuTR5LC46kX9rv/HC7JhFKIBKrDHF
|
||||||
|
bHURGKxCDqLxQnfA8gJEfU7cw9HnxMxmKv7qJ3O7EHYMuTQstkYsGOr60zX/C+Zm
|
||||||
|
7YA+d7nx1LpL0m2lKs70iz5MzGg+KgKyrkMWQ30gpxILBxNzzuQr7Kv/+63/3+G9
|
||||||
|
nfCGeLmwGakPFpm6/GwiABE0yGa71YNAQs18iUTZwP/ZEDw3KB2SoG8wcqWjNAd+
|
||||||
|
cUF2PgECgYEA5Xe/OZouw9h0NBo0Zut+HC0YOuUfY72Ug9Fm8bAS6wDuPiO3jIvK
|
||||||
|
J40d+ZHNp4AakfTuugiqEDJRlV7T/F2K/KHDWvXTg5ZpAC8dsZKJMxyyAp8EniYQ
|
||||||
|
vsoFWeHBfsD83rCVKLcjDB3hbQH+MSoT3lsqjZRNiNUMK13gyuX7k28CgYEA4SWF
|
||||||
|
ySRXUqUezX5D8kV5rQVYLcw6WVB3czYd7cKf8zHy4xJX0ZicyZjohknMmKCkdx+M
|
||||||
|
1mrxlqUO7EBGokM8vs87m/4rz6bjgZffpWzUmP/x1+3f3j/wIZeqNilW8NqY5nLi
|
||||||
|
tj3JxMwaesU86rOekSy27BlX4sjQ8NRs7Z2d8sECgYBKAD8kBWwVbqWy88x4cHOA
|
||||||
|
BK7ut1tTIB1YEVzgjobbULaERaJ46c/sx16mUHYBEZf///xI9Ghbxs52nFlC5qve
|
||||||
|
4xAMMoDey8/a5lbuIDKs0BE8NSoZEm+OB7qIDP0IspYZ/tprgfwEeVJshBsEoew8
|
||||||
|
Ziwn8m66tPIyvhizdk2WcwKBgH2M8RgDffaGQbESEk3N1FZZvpx7YKZhqtrCeNoX
|
||||||
|
SB7T4cAigHpPAk+hRzlref46xrvvChiftmztSm8QQNNHb15wLauFh2Taic/Ao2Sa
|
||||||
|
VcukHnbtHYPQX9Y7vx1I3ESfgdgwhKBfwF5P+wwvZRL0ax5FsxPh5hJ/LZS+wKeY
|
||||||
|
13WBAoGAXSqG3ANmCyvSLVmAXGIbr0Tuixf/a25sPrlq7Im1H1OnqLrcyxWCLV3E
|
||||||
|
6gprhG5An0Zlr/FFRxVojf0TKmtJZs9B70/6WPwVvFtBduCM1zuUuCQYU9opTJQL
|
||||||
|
ElMIP4VfjABm4tm1fqGIy1PQP0Osb6/qb2DPPJqsFiW0oRByyMA=
|
||||||
|
-----END RSA PRIVATE KEY-----
|
13
internal/testdata/testdata_suite_test.go
vendored
Normal file
13
internal/testdata/testdata_suite_test.go
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package testdata
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTestdata(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "Testdata Suite")
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue