Skip to content

Commit 3d9275d

Browse files
authored
Merge branch 'main' into tsa-inclusive
2 parents d8b113c + 8a20716 commit 3d9275d

11 files changed

Lines changed: 55 additions & 60 deletions

File tree

.github/workflows/build-binaries.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
on: [push, pull_request]
22
name: Build binaries
3+
permissions:
4+
contents: read
5+
packages: write
36
jobs:
47
build-macos:
58
strategy:
69
matrix:
7-
go-version: ["1.17"]
10+
go-version: ["1.23"]
811
os: [macos-latest]
912
runs-on: ${{ matrix.os }}
1013
env:
@@ -34,23 +37,23 @@ jobs:
3437
# We cd so that the binary ends up in the top level of the tar.
3538
cd build/macos && tar -czvf smimesign-macos-${{ env.GIT_VERSION }}.tgz smimesign
3639
- name: Upload build folder to the action
37-
uses: actions/upload-artifact@v2
40+
uses: actions/upload-artifact@v4
3841
with:
3942
# Note: this artifact is shared across jobs:
4043
# https://github.com/actions/upload-artifact#uploading-to-the-same-artifact
4144
name: build
4245
path: build/
4346
- name: Upload macOS files to the release
44-
# Pinned hash from https://github.com/softprops/action-gh-release/releases/tag/v0.1.12
45-
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb
47+
# Pinned hash from https://github.com/softprops/action-gh-release/releases/tag/v2.0.8
48+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
4649
if: startsWith(github.ref, 'refs/tags/v')
4750
with:
4851
files: |
4952
build/macOS/smimesign-macos-${{ env.GIT_VERSION }}.tgz
5053
build-windows:
5154
strategy:
5255
matrix:
53-
go-version: ["1.17"]
56+
go-version: ["1.23"]
5457
os: [windows-latest]
5558
runs-on: ${{ matrix.os }}
5659
env:
@@ -88,8 +91,8 @@ jobs:
8891
run: |
8992
GOARCH=amd64 go build -o "build/amd64/smimesign.exe" -ldflags "-X main.versionString=${{ env.GIT_VERSION }}"
9093
- name: Switch MinGW to x86
91-
# Pinned hash from https://github.com/egor-tensin/setup-mingw/releases/tag/v2
92-
uses: egor-tensin/setup-mingw@f3c5d799aadf8fa230ac67a422b01dd085bbc96b
94+
# Pinned hash from https://github.com/egor-tensin/setup-mingw/releases/tag/v2.2.0
95+
uses: egor-tensin/setup-mingw@84c781b557efd538dec66bde06988d81cd3138cf
9396
with:
9497
platform: x86
9598
- name: Build 386
@@ -119,15 +122,15 @@ jobs:
119122
mv build/amd64/smimesign.zip build/amd64/smimesign-windows-amd64-${{ env.GIT_VERSION }}.zip
120123
mv build/386/smimesign.zip build/386/smimesign-windows-386-${{ env.GIT_VERSION }}.zip
121124
- name: Upload build folder to the action
122-
uses: actions/upload-artifact@v2
125+
uses: actions/upload-artifact@v4
123126
with:
124127
# Note: this artifact is shared across jobs:
125128
# https://github.com/actions/upload-artifact#uploading-to-the-same-artifact
126129
name: build
127130
path: build/
128131
- name: Upload Windows files to the release
129-
# Pinned hash from https://github.com/softprops/action-gh-release/releases/tag/v0.1.12
130-
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb
132+
# Pinned hash from https://github.com/softprops/action-gh-release/releases/tag/v2.0.8
133+
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
131134
if: startsWith(github.ref, 'refs/tags/v')
132135
with:
133136
files: |
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
on: [push, pull_request]
2-
name: Test macOS
2+
name: Test
3+
permissions:
4+
contents: read
35
jobs:
46
test:
57
strategy:
68
matrix:
7-
go-version: ["1.14", "1.x"]
8-
os: [macos-latest]
9+
go-version: ["1.22", "1.x"]
10+
os: [macos-latest, windows-latest]
911
runs-on: ${{ matrix.os }}
1012
env:
1113
CGO_ENABLED: 1

.github/workflows/test-windows-go.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

certstore/certstore_darwin.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ func (i *macIdentity) CertificateChain() ([]*x509.Certificate, error) {
160160
}
161161
defer C.CFRelease(C.CFTypeRef(trustRef))
162162

163-
var status C.SecTrustResultType
164-
if err := osStatusError(C.SecTrustEvaluate(trustRef, &status)); err != nil {
163+
var cfError C.CFErrorRef
164+
if C.SecTrustEvaluateWithError(trustRef, &cfError) {
165+
err := cfErrorError(cfError)
165166
return nil, err
166167
}
167168

@@ -171,18 +172,22 @@ func (i *macIdentity) CertificateChain() ([]*x509.Certificate, error) {
171172
)
172173

173174
for i := C.CFIndex(0); i < nchain; i++ {
174-
// TODO: do we need to release these?
175-
chainCertref := C.SecTrustGetCertificateAtIndex(trustRef, i)
176-
if chainCertref == nilSecCertificateRef {
177-
return nil, errors.New("nil certificate in chain")
175+
chainCertCpy := C.SecTrustCopyCertificateChain(trustRef)
176+
177+
if C.CFArrayRef(chainCertCpy) == nilCFArrayRef {
178+
return nil, errors.New("nil certificate in the chain")
178179
}
179180

180-
chainCert, err := exportCertRef(chainCertref)
181+
chainCertRef := C.SecCertificateRef(C.CFArrayGetValueAtIndex(chainCertCpy, i))
182+
183+
chainCert, err := exportCertRef(chainCertRef)
181184
if err != nil {
182185
return nil, err
183186
}
184187

185188
chain = append(chain, chainCert)
189+
190+
C.CFRelease(C.CFTypeRef(chainCertCpy))
186191
}
187192

188193
i.chain = chain

certstore/certstore_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ func (c errCode) Error() string {
637637
if cmsg == nil {
638638
return fmt.Sprintf("Error %X", int(c))
639639
}
640-
defer C.LocalFree(C.HLOCAL(cmsg))
640+
defer C.LocalFree(C.HLOCAL(unsafe.Pointer(cmsg)))
641641

642642
gomsg := C.GoString(cmsg)
643643

go.mod

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
module github.com/github/smimesign
22

3-
go 1.12
3+
go 1.22.7
44

55
require (
66
github.com/certifi/gocertifi v0.0.0-20180118203423-deb3ae2ef261
7-
github.com/davecgh/go-spew v1.1.1 // indirect
87
github.com/pborman/getopt v0.0.0-20180811024354-2b5b3bfb099b
98
github.com/pkg/errors v0.8.1
109
github.com/stretchr/testify v1.3.0
11-
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734
12-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
10+
golang.org/x/crypto v0.27.0
11+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
12+
)
13+
14+
require (
15+
github.com/davecgh/go-spew v1.1.1 // indirect
16+
github.com/pmezard/go-difflib v1.0.0 // indirect
1317
)

go.sum

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
1212
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1313
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
1414
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
15-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
16-
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo=
17-
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
18-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
19-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
20-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
21-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
22-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
23-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
15+
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
16+
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
17+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
18+
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=

ietf-cms/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ der, _ := cms.Sign(msg, []*x509.Certificate{cert}, key)
1818
//
1919

2020
sd, _ := ParseSignedData(der)
21-
if err, _ := sd.Verify(x509.VerifyOptions{}); err != nil {
21+
if _, err := sd.Verify(x509.VerifyOptions{}); err != nil {
2222
panic(err)
2323
}
2424
```
@@ -37,7 +37,7 @@ der, _ := cms.SignDetached(msg, cert, key)
3737
//
3838

3939
sd, _ := ParseSignedData(der)
40-
if err, _ := sd.VerifyDetached(msg, x509.VerifyOptions{}); err != nil {
40+
if _, err := sd.VerifyDetached(msg, x509.VerifyOptions{}); err != nil {
4141
panic(err)
4242
}
4343
```

ietf-cms/verify_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ func TestVerifyOpenSSLDetached(t *testing.T) {
133133
}
134134

135135
func TestVerifyOutlookDetached(t *testing.T) {
136+
t.Skip("Test fails. See https://github.com/github/smimesign/issues/150")
137+
136138
sd, err := ParseSignedData(fixtureSignatureOutlookDetached)
137139
if err != nil {
138140
t.Fatal(err)
@@ -144,6 +146,8 @@ func TestVerifyOutlookDetached(t *testing.T) {
144146
}
145147

146148
func TestVerifySmimesignAttachedWithTimestamp(t *testing.T) {
149+
t.Skip("Test fails. See https://github.com/github/smimesign/issues/150")
150+
147151
sd, err := ParseSignedData(fixtureSmimesignAttachedWithTimestamp)
148152
if err != nil {
149153
t.Fatal(err)

parse_user_id.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import "strings"
44

55
// The following was copied from the crypto/openpgpg/packet package.
66

7-
// The original license can be found at https://git.io/vFFwQ
7+
// The original license can be found at
8+
// https://github.com/golang/crypto/blob/9f005a07e0d31d45e6656d241bb5c0f2efd4bc94/LICENSE
89
//
910
// Copyright (c) 2009 The Go Authors. All rights reserved.
1011
//
@@ -34,7 +35,8 @@ import "strings"
3435
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3536
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3637

37-
// The orignal code can be found at https://git.io/vFFwX
38+
// The orignal code can be found at
39+
// https://github.com/golang/crypto/blob/9f005a07e0d31d45e6656d241bb5c0f2efd4bc94/openpgp/packet/userid.go#L89-L160
3840
//
3941
// parseUserID extracts the name, comment and email from a user id string that
4042
// is formatted as "Full Name (Comment) <email@example.com>".

0 commit comments

Comments
 (0)