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
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, go: '1.26' }
- { os: windows-latest, go: '1.26' }
- { os: ubuntu-latest, go: '1.20' }
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 0
GOTOOLCHAIN: local
steps:
# Keep testdata byte-exact: autocrlf on Windows runners rewrites LF.
- name: Disable CRLF conversion
if: runner.os == 'Windows'
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
# go.mod says go 1.20, so loopclosure flags upstream Go tests that assume
# per-iteration loop variables; the rest of vet stays on.
- name: Vet
if: matrix.go == '1.26'
run: go vet -loopclosure=false ./...
- name: Test
run: go test -count=1 ./...

race:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: '1.26'
- name: Test with the race detector
run: go test -race -count=1 ./...
46 changes: 0 additions & 46 deletions .github/workflows/go.yml

This file was deleted.

6 changes: 5 additions & 1 deletion handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,11 @@ func testUtlsHandshake(t *testing.T, clientConfig, serverConfig *Config, spec *C
}
if spec != nil {
ucli := UClient(c, clientConfig, HelloCustom)
if err = ucli.ApplyPreset(spec); err != nil {
// Do not assign to the outer err: the test goroutine writes it
// concurrently, and returning without a send would block it.
if err := ucli.ApplyPreset(spec); err != nil {
errChan <- fmt.Errorf("client: %v", err)
c.Close()
return
}
cli = ucli
Expand Down
37 changes: 22 additions & 15 deletions resumption_trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"math/big"
"testing"
"time"
)
Expand All @@ -29,6 +30,7 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {

createChain := func(leafNotAfter, rootNotAfter time.Time) (leafDER, expiredLeafDER []byte, root *x509.Certificate) {
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: "root"},
NotBefore: rootNotAfter.Add(-time.Hour * 24),
NotAfter: rootNotAfter,
Expand All @@ -45,11 +47,12 @@ func testHandshakeChainExpiryResumption(t *testing.T, version uint16) {
}

tmpl = &x509.Certificate{
Subject: pkix.Name{},
DNSNames: []string{"expired-resume.example.com"},
NotBefore: leafNotAfter.Add(-time.Hour * 24),
NotAfter: leafNotAfter,
KeyUsage: x509.KeyUsageDigitalSignature,
SerialNumber: big.NewInt(2),
Subject: pkix.Name{},
DNSNames: []string{"expired-resume.example.com"},
NotBefore: leafNotAfter.Add(-time.Hour * 24),
NotAfter: leafNotAfter,
KeyUsage: x509.KeyUsageDigitalSignature,
}
leafCertDER, err := x509.CreateCertificate(rand.Reader, tmpl, root, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
if err != nil {
Expand Down Expand Up @@ -148,6 +151,7 @@ func TestHandshakeGetConfigForClientDifferentClientCAs(t *testing.T) {
func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uint16) {
now := time.Now()
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: "root"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
Expand All @@ -172,11 +176,12 @@ func testHandshakeGetConfigForClientDifferentClientCAs(t *testing.T, version uin
}

tmpl = &x509.Certificate{
Subject: pkix.Name{},
DNSNames: []string{"example.com"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
SerialNumber: big.NewInt(2),
Subject: pkix.Name{},
DNSNames: []string{"example.com"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
}
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
if err != nil {
Expand Down Expand Up @@ -266,6 +271,7 @@ func TestHandshakeChangeRootCAsResumption(t *testing.T) {
func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
now := time.Now()
tmpl := &x509.Certificate{
SerialNumber: big.NewInt(1),
Subject: pkix.Name{CommonName: "root"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
Expand All @@ -290,11 +296,12 @@ func testHandshakeChangeRootCAsResumption(t *testing.T, version uint16) {
}

tmpl = &x509.Certificate{
Subject: pkix.Name{},
DNSNames: []string{"example.com"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
SerialNumber: big.NewInt(2),
Subject: pkix.Name{},
DNSNames: []string{"example.com"},
NotBefore: now.Add(-time.Hour * 24),
NotAfter: now.Add(time.Hour * 24),
KeyUsage: x509.KeyUsageDigitalSignature,
}
certA, err := x509.CreateCertificate(rand.Reader, tmpl, rootA, &testECDSAPrivateKey.PublicKey, testECDSAPrivateKey)
if err != nil {
Expand Down
Loading