Skip to content

Commit 00b6080

Browse files
authored
sync: update CI config files (libp2p#34)
1 parent 176c5cd commit 00b6080

14 files changed

+90
-91
lines changed

.github/workflows/go-check.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
env:
1212
RUNGOGENERATE: false
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
with:
1616
submodules: recursive
17-
- uses: actions/setup-go@v2
17+
- uses: actions/setup-go@v3
1818
with:
19-
go-version: "1.18.x"
19+
go-version: "1.19.x"
2020
- name: Run repo-specific setup
2121
uses: ./.github/actions/go-check-setup
2222
if: hashFiles('./.github/actions/go-check-setup') != ''
@@ -27,7 +27,7 @@ jobs:
2727
echo "RUNGOGENERATE=true" >> $GITHUB_ENV
2828
fi
2929
- name: Install staticcheck
30-
run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0)
30+
run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3)
3131
- name: Check that go.mod is tidy
3232
uses: protocol/[email protected]
3333
with:

.github/workflows/go-test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
os: [ "ubuntu", "windows", "macos" ]
13-
go: [ "1.17.x", "1.18.x" ]
13+
go: [ "1.18.x", "1.19.x" ]
1414
env:
1515
COVERAGES: ""
1616
runs-on: ${{ format('{0}-latest', matrix.os) }}
1717
name: ${{ matrix.os }} (go ${{ matrix.go }})
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
submodules: recursive
22-
- uses: actions/setup-go@v2
22+
- uses: actions/setup-go@v3
2323
with:
2424
go-version: ${{ matrix.go }}
2525
- name: Go information
@@ -43,7 +43,7 @@ jobs:
4343
# Use -coverpkg=./..., so that we include cross-package coverage.
4444
# If package ./A imports ./B, and ./A's tests also cover ./B,
4545
# this means ./B's coverage will be significantly higher than 0%.
46-
run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./...
46+
run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./...
4747
- name: Run tests (32 bit)
4848
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
4949
uses: protocol/[email protected]
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
run: |
5454
export "PATH=${{ env.PATH_386 }}:$PATH"
55-
go test -v ./...
55+
go test -v -shuffle=on ./...
5656
- name: Run tests with race detector
5757
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
5858
uses: protocol/[email protected]
@@ -62,7 +62,7 @@ jobs:
6262
shell: bash
6363
run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV
6464
- name: Upload coverage to Codecov
65-
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
65+
uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0
6666
with:
6767
files: '${{ env.COVERAGES }}'
6868
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}

build.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
//go:build !openssl_static
16-
// +build !openssl_static
1716

1817
package openssl
1918

build_static.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
//go:build openssl_static
16-
// +build openssl_static
1716

1817
package openssl
1918

cert.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "C"
1919

2020
import (
2121
"errors"
22-
"io/ioutil"
22+
"io"
2323
"math/big"
2424
"runtime"
2525
"time"
@@ -383,7 +383,7 @@ func (c *Certificate) MarshalPEM() (pem_block []byte, err error) {
383383
if int(C.PEM_write_bio_X509(bio, c.x)) != 1 {
384384
return nil, errors.New("failed dumping certificate")
385385
}
386-
return ioutil.ReadAll(asAnyBio(bio))
386+
return io.ReadAll(asAnyBio(bio))
387387
}
388388

389389
// PublicKey returns the public key embedded in the X509 certificate.

ctx.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import "C"
2020
import (
2121
"errors"
2222
"fmt"
23-
"io/ioutil"
2423
"os"
2524
"runtime"
2625
"sync"
@@ -121,7 +120,7 @@ func NewCtxFromFiles(cert_file string, key_file string) (*Ctx, error) {
121120
return nil, err
122121
}
123122

124-
cert_bytes, err := ioutil.ReadFile(cert_file)
123+
cert_bytes, err := os.ReadFile(cert_file)
125124
if err != nil {
126125
return nil, err
127126
}
@@ -152,7 +151,7 @@ func NewCtxFromFiles(cert_file string, key_file string) (*Ctx, error) {
152151
}
153152
}
154153

155-
key_bytes, err := ioutil.ReadFile(key_file)
154+
key_bytes, err := os.ReadFile(key_file)
156155
if err != nil {
157156
return nil, err
158157
}

fips.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ package openssl
2525
2626
*/
2727
import "C"
28-
import "errors"
29-
import "runtime"
28+
import (
29+
"errors"
30+
"runtime"
31+
)
3032

3133
// FIPSModeSet enables a FIPS 140-2 validated mode of operation.
3234
// https://wiki.openssl.org/index.php/FIPS_mode_set()

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ require (
77

88
require golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
99

10-
go 1.17
10+
go 1.18

init.go

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,65 +18,69 @@ Package openssl is a light wrapper around OpenSSL for Go.
1818
It strives to provide a near-drop-in replacement for the Go standard library
1919
tls package, while allowing for:
2020
21-
Performance
21+
# Performance
2222
2323
OpenSSL is battle-tested and optimized C. While Go's built-in library shows
2424
great promise, it is still young and in some places, inefficient. This simple
2525
OpenSSL wrapper can often do at least 2x with the same cipher and protocol.
2626
2727
On my lappytop, I get the following benchmarking speeds:
28-
BenchmarkSHA1Large_openssl 1000 2611282 ns/op 401.56 MB/s
29-
BenchmarkSHA1Large_stdlib 500 3963983 ns/op 264.53 MB/s
30-
BenchmarkSHA1Small_openssl 1000000 3476 ns/op 0.29 MB/s
31-
BenchmarkSHA1Small_stdlib 5000000 550 ns/op 1.82 MB/s
32-
BenchmarkSHA256Large_openssl 200 8085314 ns/op 129.69 MB/s
33-
BenchmarkSHA256Large_stdlib 100 18948189 ns/op 55.34 MB/s
34-
BenchmarkSHA256Small_openssl 1000000 4262 ns/op 0.23 MB/s
35-
BenchmarkSHA256Small_stdlib 1000000 1444 ns/op 0.69 MB/s
36-
BenchmarkOpenSSLThroughput 100000 21634 ns/op 47.33 MB/s
37-
BenchmarkStdlibThroughput 50000 58974 ns/op 17.36 MB/s
38-
39-
Interoperability
28+
29+
BenchmarkSHA1Large_openssl 1000 2611282 ns/op 401.56 MB/s
30+
BenchmarkSHA1Large_stdlib 500 3963983 ns/op 264.53 MB/s
31+
BenchmarkSHA1Small_openssl 1000000 3476 ns/op 0.29 MB/s
32+
BenchmarkSHA1Small_stdlib 5000000 550 ns/op 1.82 MB/s
33+
BenchmarkSHA256Large_openssl 200 8085314 ns/op 129.69 MB/s
34+
BenchmarkSHA256Large_stdlib 100 18948189 ns/op 55.34 MB/s
35+
BenchmarkSHA256Small_openssl 1000000 4262 ns/op 0.23 MB/s
36+
BenchmarkSHA256Small_stdlib 1000000 1444 ns/op 0.69 MB/s
37+
BenchmarkOpenSSLThroughput 100000 21634 ns/op 47.33 MB/s
38+
BenchmarkStdlibThroughput 50000 58974 ns/op 17.36 MB/s
39+
40+
# Interoperability
4041
4142
Many systems support OpenSSL with a variety of plugins and modules for things,
4243
such as hardware acceleration in embedded devices.
4344
44-
Greater flexibility and configuration
45+
# Greater flexibility and configuration
4546
4647
OpenSSL allows for far greater configuration of corner cases and backwards
4748
compatibility (such as support of SSLv2). You shouldn't be using SSLv2 if you
4849
can help but, but sometimes you can't help it.
4950
50-
Security
51+
# Security
5152
5253
Yeah yeah, Heartbleed. But according to the author of the standard library's
5354
TLS implementation, Go's TLS library is vulnerable to timing attacks. And
5455
whether or not OpenSSL received the appropriate amount of scrutiny
5556
pre-Heartbleed, it sure is receiving it now.
5657
57-
Usage
58+
# Usage
5859
5960
Starting an HTTP server that uses OpenSSL is very easy. It's as simple as:
60-
log.Fatal(openssl.ListenAndServeTLS(
61-
":8443", "my_server.crt", "my_server.key", myHandler))
61+
62+
log.Fatal(openssl.ListenAndServeTLS(
63+
":8443", "my_server.crt", "my_server.key", myHandler))
6264
6365
Getting a net.Listener that uses OpenSSL is also easy:
64-
ctx, err := openssl.NewCtxFromFiles("my_server.crt", "my_server.key")
65-
if err != nil {
66-
log.Fatal(err)
67-
}
68-
l, err := openssl.Listen("tcp", ":7777", ctx)
66+
67+
ctx, err := openssl.NewCtxFromFiles("my_server.crt", "my_server.key")
68+
if err != nil {
69+
log.Fatal(err)
70+
}
71+
l, err := openssl.Listen("tcp", ":7777", ctx)
6972
7073
Making a client connection is straightforward too:
71-
ctx, err := NewCtx()
72-
if err != nil {
73-
log.Fatal(err)
74-
}
75-
err = ctx.LoadVerifyLocations("/etc/ssl/certs/ca-certificates.crt", "")
76-
if err != nil {
77-
log.Fatal(err)
78-
}
79-
conn, err := openssl.Dial("tcp", "localhost:7777", ctx, 0)
74+
75+
ctx, err := NewCtx()
76+
if err != nil {
77+
log.Fatal(err)
78+
}
79+
err = ctx.LoadVerifyLocations("/etc/ssl/certs/ca-certificates.crt", "")
80+
if err != nil {
81+
log.Fatal(err)
82+
}
83+
conn, err := openssl.Dial("tcp", "localhost:7777", ctx, 0)
8084
8185
Help wanted: To get this library to work with net/http's client, we
8286
had to fork net/http. It would be nice if an alternate http client library

init_posix.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// limitations under the License.
1414

1515
//go:build (linux || darwin || solaris || freebsd || openbsd) && !windows
16-
// +build linux darwin solaris freebsd openbsd
17-
// +build !windows
1816

1917
package openssl
2018

init_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
//go:build windows
16-
// +build windows
1716

1817
package openssl
1918

key.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import "C"
1919

2020
import (
2121
"errors"
22-
"io/ioutil"
22+
"io"
2323
"runtime"
2424
"unsafe"
2525
)
@@ -242,7 +242,7 @@ func (key *pKey) MarshalPKCS1PrivateKeyPEM() (pem_block []byte,
242242
return nil, errors.New("failed dumping private key")
243243
}
244244

245-
return ioutil.ReadAll(asAnyBio(bio))
245+
return io.ReadAll(asAnyBio(bio))
246246
}
247247

248248
func (key *pKey) MarshalPKCS1PrivateKeyDER() (der_block []byte,
@@ -257,7 +257,7 @@ func (key *pKey) MarshalPKCS1PrivateKeyDER() (der_block []byte,
257257
return nil, errors.New("failed dumping private key der")
258258
}
259259

260-
return ioutil.ReadAll(asAnyBio(bio))
260+
return io.ReadAll(asAnyBio(bio))
261261
}
262262

263263
func (key *pKey) MarshalPKIXPublicKeyPEM() (pem_block []byte,
@@ -272,7 +272,7 @@ func (key *pKey) MarshalPKIXPublicKeyPEM() (pem_block []byte,
272272
return nil, errors.New("failed dumping public key pem")
273273
}
274274

275-
return ioutil.ReadAll(asAnyBio(bio))
275+
return io.ReadAll(asAnyBio(bio))
276276
}
277277

278278
func (key *pKey) MarshalPKIXPublicKeyDER() (der_block []byte,
@@ -287,7 +287,7 @@ func (key *pKey) MarshalPKIXPublicKeyDER() (der_block []byte,
287287
return nil, errors.New("failed dumping public key der")
288288
}
289289

290-
return ioutil.ReadAll(asAnyBio(bio))
290+
return io.ReadAll(asAnyBio(bio))
291291
}
292292

293293
// LoadPrivateKeyFromPEM loads a private key from a PEM-encoded block.

0 commit comments

Comments
 (0)